GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "predict.h"
#include "df.h"
#include "memmodel.h"
#include "tm_p.h"
#include "insn-config.h"
#include "regs.h"
#include "ira.h"
#include "ira-int.h"
#include "recog.h"
#include "cfganal.h"
#include "sparseset.h"
#include "lra-int.h"
#include "target.h"
#include "function-abi.h"
Data Structures | |
class | bb_data_pseudos |
Typedefs | |
typedef class bb_data_pseudos * | bb_data_t |
Enumerations | |
enum | point_type { DEF_POINT , USE_POINT } |
Variables | |
int | lra_live_max_point |
int | lra_hard_reg_usage [FIRST_PSEUDO_REGISTER] |
static bool | complete_info_p |
static sparseset | pseudos_live |
static sparseset | pseudos_live_through_calls |
static sparseset | pseudos_live_through_setjumps |
static HARD_REG_SET | hard_regs_live |
static sparseset | start_living |
static sparseset | start_dying |
static sparseset | unused_set |
static sparseset | dead_set |
static bitmap_head | temp_bitmap |
static object_allocator< lra_live_range > | lra_live_range_pool ("live ranges") |
static bitmap | bb_killed_pseudos |
static bitmap | bb_gen_pseudos |
static bb_data_t | bb_data |
static bitmap_head | all_hard_regs_bitmap |
static bitmap_head | all_blocks |
static rtx_insn * | curr_insn |
static lra_insn_recog_data_t | curr_id |
static struct lra_static_insn_data * | curr_static_id |
static vec< int > | point_freq_vec |
int * | lra_point_freq |
int | lra_live_range_iter |
typedef class bb_data_pseudos* bb_data_t |
Array for all BB data. Indexed by the corresponding BB index.
enum point_type |
|
inlinestatic |
Check whether REGNO lives through calls and setjmps and clear the corresponding bits in PSEUDOS_LIVE_THROUGH_CALLS and PSEUDOS_LIVE_THROUGH_SETJUMPS. All calls in the region described by PSEUDOS_LIVE_THROUGH_CALLS have the given ABI.
References lra_reg_info, function_abi::mode_clobbers(), PSEUDO_REGNO_MODE, pseudos_live_through_calls, pseudos_live_through_setjumps, SET_HARD_REG_SET, sparseset_bit_p(), and sparseset_clear_bit().
Referenced by process_bb_lives().
|
static |
Clear pseudo REGNO in SET or all hard registers of REGNO in MODE in SET.
References dead_set, end_hard_regno(), last, and sparseset_clear_bit().
Referenced by process_bb_lives().
|
static |
Compress pseudo live ranges.
References lra_dump_file, NULL, print_live_ranges(), and remove_some_program_points_and_update_live_ranges().
Referenced by lra_create_live_ranges_1().
|
static |
Copy live range R and return the result.
References lra_live_range_pool, and r.
Referenced by lra_copy_live_range_list().
|
static |
Create and return pseudo live range with given attributes.
References lra_live_range::finish, lra_live_range_pool, lra_live_range::next, lra_live_range::regno, and lra_live_range::start.
Referenced by update_pseudo_point().
DEBUG_FUNCTION void debug | ( | lra_live_range & | ref | ) |
References lra_print_live_range_list().
DEBUG_FUNCTION void debug | ( | lra_live_range * | ptr | ) |
References debug.
|
static |
Free all data needed for global pseudo live analysis.
References all_blocks, all_hard_regs_bitmap, bb_data_pseudos::bb, bitmap_clear(), cfun, FOR_ALL_BB_FN, free(), and get_bb_data().
Referenced by lra_live_ranges_finish().
|
static |
Free live range list LR.
References lra_live_range_pool, lra_live_range::next, and NULL.
Referenced by lra_clear_live_ranges().
|
inlinestatic |
Two small functions for access to the bb data.
References bb_data_pseudos::bb.
Referenced by finish_live_solver(), initiate_live_solver(), live_trans_fun(), lra_create_live_ranges_1(), and process_bb_lives().
|
inlinestatic |
Referenced by live_trans_fun().
|
static |
Allocate and initialize data needed for global pseudo live analysis.
References all_blocks, all_hard_regs_bitmap, bb_data_pseudos::bb, bitmap_initialize(), bitmap_set_bit, bitmap_set_range(), cfun, FOR_ALL_BB_FN, get_bb_data(), basic_block_def::index, last_basic_block_for_fn, and reg_obstack.
Referenced by lra_live_ranges_init().
|
static |
The confluence function used by the DF equation solver to set up live info for a block BB without predecessor.
References all_hard_regs_bitmap, bb_data_pseudos::bb, bitmap_and_into(), and df_get_live_out().
Referenced by lra_create_live_ranges_1().
The confluence function used by the DF equation solver to propagate live info from successor to predecessor on edge E according to the following equation: bb.liveout = 0 for entry block | OR (livein of successors)
References all_hard_regs_bitmap, bb_data_pseudos::bb, bitmap_ior_and_compl_into(), df_get_live_in(), and df_get_live_out().
Referenced by lra_create_live_ranges_1().
|
static |
The transfer function used by the DF equation solver to propagate live info through block with BB_INDEX according to the following equation: bb.livein = (bb.liveout - bb.kill) OR bb.gen
References all_hard_regs_bitmap, bb_data_pseudos::bb, bitmap_and_compl(), bitmap_ior_and_compl(), df_get_live_in(), df_get_live_out(), get_bb_data(), get_bb_data_by_index(), and temp_bitmap.
Referenced by lra_create_live_ranges_1().
void lra_clear_live_ranges | ( | void | ) |
Finish all live ranges.
References free_live_range_list(), i, lra_reg_info, max_reg_num(), and point_freq_vec.
Referenced by lra(), and lra_create_live_ranges().
lra_live_range_t lra_copy_live_range_list | ( | lra_live_range_t | r | ) |
Copy live range list given by its head R and return the result.
References copy_live_range(), lra_live_range::next, NULL, and r.
Referenced by add_pseudo_to_slot(), and merge_pseudos().
The main entry function creates live-ranges and other live info necessary for the assignment sub-pass. It uses lra_creates_live_ranges_1 -- so read comments for the function.
References lra_assert, lra_clear_live_ranges(), lra_create_live_ranges_1(), lra_dump_file, and NULL.
Referenced by lra().
The function creates live ranges only for memory pseudos (or for all ones if ALL_P), set up CONFLICT_HARD_REGS for the pseudos. It also does dead insn elimination if DEAD_INSN_P and global live analysis only for pseudos and only if the pseudo live info was changed on a BB border. Return TRUE if the live info was changed.
References all_blocks, all_hard_regs_bitmap, BASIC_BLOCK_FOR_FN, bitmap_clear_bit(), bitmap_clear_range(), cfun, CLEAR_HARD_REG_SET, complete_info_p, compress_live_ranges(), curr_point, dead_set, DF_BACKWARD, df_get_live_in(), df_get_live_out(), df_get_n_blocks(), df_get_postorder(), df_simple_dataflow(), ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_BB_FN, free(), get_bb_data(), get_max_uid(), GET_MODE, HARD_REGISTER_NUM_P, hard_regs_spilled_into, i, basic_block_def::index, inverted_rev_post_order_compute(), live_con_fun_0(), live_con_fun_n(), live_trans_fun(), lra_assert, lra_dump_bitmap_with_title(), lra_dump_file, lra_free_copies(), lra_hard_reg_usage, lra_live_max_point, lra_live_range_iter, lra_point_freq, lra_reg_info, max_reg_num(), max_regno, n_basic_blocks_for_fn, NULL, NULL_RTX, point_freq_vec, print_live_ranges(), process_bb_lives(), pseudos_live, pseudos_live_through_calls, pseudos_live_through_setjumps, reg_renumber, regno_reg_rtx, sparseset_alloc(), sparseset_free, start_dying, start_living, TEST_HARD_REG_BIT, timevar_pop(), timevar_push(), and unused_set.
Referenced by lra_create_live_ranges().
void lra_debug_live_range_list | ( | lra_live_range_t | r | ) |
Print live ranges R to stderr.
References lra_print_live_range_list(), and r.
void lra_debug_live_ranges | ( | void | ) |
Print live ranges of all pseudos to stderr.
References print_live_ranges().
void lra_debug_pseudo_live_ranges | ( | int | regno | ) |
Print live ranges of pseudo REGNO to stderr.
References print_pseudo_live_ranges(), and lra_insn_reg::regno.
bool lra_intersected_live_ranges_p | ( | lra_live_range_t | r1, |
lra_live_range_t | r2 ) |
Return TRUE if live ranges R1 and R2 intersect.
References lra_live_range::finish, lra_live_range::next, NULL, and lra_live_range::start.
Referenced by assign_stack_slot_num_and_sort_pseudos(), and lra_coalesce().
void lra_live_ranges_finish | ( | void | ) |
Finish live ranges data once per function.
References bitmap_clear(), finish_live_solver(), lra_live_range_pool, and temp_bitmap.
Referenced by lra().
void lra_live_ranges_init | ( | void | ) |
Initialize live ranges data once per function.
References bitmap_initialize(), initiate_live_solver(), reg_obstack, and temp_bitmap.
Referenced by lra().
lra_live_range_t lra_merge_live_ranges | ( | lra_live_range_t | r1, |
lra_live_range_t | r2 ) |
Merge *non-intersected* ranges R1 and R2 and returns the result. The function maintains the order of ranges and tries to minimize size of the result range list. Ranges R1 and R2 may not be used after the call.
References lra_live_range::finish, gcc_assert, last, lra_assert, lra_live_range_pool, lra_live_range::next, NULL, and lra_live_range::start.
Referenced by add_pseudo_to_slot(), and merge_pseudos().
void lra_print_live_range_list | ( | FILE * | f, |
lra_live_range_t | r ) |
Print live ranges R to file F.
Referenced by debug(), lra_debug_live_range_list(), and print_pseudo_live_ranges().
void lra_setup_reload_pseudo_preferenced_hard_reg | ( | int | regno, |
int | hard_regno, | ||
int | profit ) |
Update the preference of HARD_REGNO for pseudo REGNO by PROFIT.
References lra_assert, lra_constraint_new_regno_start, lra_dump_file, lra_reg_info, and NULL.
Referenced by process_bb_lives(), and update_hard_regno_preference().
|
static |
Process the definition of hard register REGNO. This updates hard_regs_live, START_DYING and conflict hard regs for living pseudos.
References bb_gen_pseudos, bb_killed_pseudos, bitmap_clear_bit(), bitmap_set_bit, CLEAR_HARD_REG_BIT, eliminable_regset, EXECUTE_IF_SET_IN_SPARSESET, fixed_regs, HARD_REGISTER_NUM_P, hard_regs_live, hard_regs_spilled_into, i, lra_assert, lra_reg_info, pseudos_live, SET_HARD_REG_BIT, sparseset_set_bit(), start_dying, and TEST_HARD_REG_BIT.
Referenced by process_bb_lives().
|
static |
Record hard register REGNO as now being live. It updates living hard regs and START_LIVING.
References bb_gen_pseudos, bitmap_set_bit, eliminable_regset, fixed_regs, HARD_REGISTER_NUM_P, hard_regs_live, hard_regs_spilled_into, lra_assert, SET_HARD_REG_BIT, sparseset_set_bit(), start_living, and TEST_HARD_REG_BIT.
Referenced by process_bb_lives().
|
static |
Mark pseudo REGNO as now being dead and update START_DYING.
References HARD_REGISTER_NUM_P, hard_regs_live, lra_assert, lra_reg_info, pseudos_live, sparseset_bit_p(), sparseset_clear_bit(), sparseset_set_bit(), and start_dying.
Referenced by mark_regno_dead(), and process_bb_lives().
|
static |
Mark pseudo REGNO as now being live and update START_LIVING.
References HARD_REGISTER_NUM_P, lra_assert, pseudos_live, sparseset_bit_p(), sparseset_set_bit(), and start_living.
Referenced by mark_regno_live(), and process_bb_lives().
|
static |
Mark register REGNO (pseudo or hard register) in MODE as being dead and update BB_GEN_PSEUDOS and BB_KILLED_PSEUDOS.
References bb_gen_pseudos, bb_killed_pseudos, bitmap_clear_bit(), bitmap_set_bit, end_hard_regno(), HARD_REGISTER_NUM_P, last, make_hard_regno_dead(), and mark_pseudo_dead().
Referenced by process_bb_lives().
|
static |
Mark register REGNO (pseudo or hard register) in MODE as being live and update BB_GEN_PSEUDOS.
References bb_gen_pseudos, bitmap_set_bit, end_hard_regno(), HARD_REGISTER_NUM_P, last, make_hard_regno_live(), and mark_pseudo_live().
Referenced by process_bb_lives().
|
static |
Increment the current program point POINT to the next point which has execution frequency FREQ.
References lra_point_freq, and point_freq_vec.
Referenced by process_bb_lives().
|
static |
Print live ranges of all pseudos to file F.
References i, max_reg_num(), max_regno, and print_pseudo_live_ranges().
Referenced by compress_live_ranges(), lra_create_live_ranges_1(), and lra_debug_live_ranges().
|
static |
Print live ranges of pseudo REGNO to file F.
References lra_print_live_range_list(), lra_reg_info, NULL, and lra_insn_reg::regno.
Referenced by lra_debug_pseudo_live_ranges(), and print_live_ranges().
|
static |
Process insns of the basic block BB to update pseudo live ranges, pseudo hard register conflicts, and insn notes. We do it on backward scan of BB insns. CURR_POINT is the program point where BB ends. The function updates this counter and returns in CURR_POINT the program point where BB starts. The function also does local live info updates and can delete the dead insns if DEAD_INSN_P. It returns true if pseudo live info was changed at the BB start.
References add_reg_note(), bb_gen_pseudos, bb_has_abnormal_pred(), bb_has_eh_pred(), bb_killed_pseudos, lra_insn_reg::biggest_mode, bitmap_bit_p, bitmap_clear(), bitmap_copy(), bitmap_set_bit, CALL_P, cfun, check_pseudos_live_through_calls(), CLEAR_HARD_REG_BIT, CLEAR_HARD_REG_SET, clear_sparseset_regnos(), complete_info_p, curr_id, curr_insn, curr_point, curr_static_id, dead_set, DEF_POINT, default_function_abi, df_get_live_in(), df_get_live_out(), eh_edge_abi, EH_RETURN_DATA_REGNO, eliminable_regset, EXECUTE_IF_SET_IN_BITMAP, EXECUTE_IF_SET_IN_SPARSESET, find_reg_note(), FOR_BB_INSNS_REVERSE_SAFE, get_bb_data(), GET_MODE, HARD_REGISTER_NUM_P, HARD_REGISTER_P, hard_regs_live, hard_regs_spilled_into, has_abnormal_call_or_eh_pred_edge_p(), i, basic_block_def::index, lra_insn_recog_data::insn, insn_callee_abi(), INSN_UID(), INVALID_REGNUM, ira_hard_reg_set_intersection_p(), lra_constraint_new_regno_start, lra_create_copy(), lra_dump_file, lra_get_insn_recog_data(), lra_hard_reg_usage, lra_reg_info, lra_reg_val_equal_p(), lra_set_insn_deleted(), lra_setup_reload_pseudo_preferenced_hard_reg(), lra_substitute_pseudo_within_insn(), lra_update_biggest_mode(), lra_update_insn_regno_info(), make_hard_regno_dead(), make_hard_regno_live(), mark_pseudo_dead(), mark_pseudo_live(), mark_regno_dead(), mark_regno_live(), may_trap_p(), lra_insn_reg::next, next_program_point(), non_conflicting_reg_copy_p(), NONDEBUG_INSN_P, NULL, NULL_RTX, OP_IN, OP_INOUT, OP_OUT, PATTERN(), pic_offset_table_rtx, pseudos_live, pseudos_live_through_calls, pseudos_live_through_setjumps, reg_early_clobber_p(), REG_FREQ_FROM_BB, REG_NOTE_KIND, REG_NOTES, REG_P, reg_renumber, REG_SET_TO_HARD_REG_SET, REGNO, lra_insn_reg::regno, regno_reg_rtx, regnos_in_sparseset_p(), SET_DEST, SET_HARD_REG_BIT, SET_SRC, single_set(), sparseset_and_compl(), sparseset_bit_p(), sparseset_cardinality(), sparseset_clear(), sparseset_clear_bit(), sparseset_contains_pseudos_p(), sparseset_copy(), sparseset_ior(), sparseset_set_bit(), start_dying, start_living, lra_insn_reg::subreg_p, targetm, temp_bitmap, TEST_HARD_REG_BIT, lra_insn_reg::type, unused_set, update_pseudo_point(), USE_POINT, volatile_refs_p(), and XEXP.
Referenced by lra_create_live_ranges_1().
|
inlinestatic |
Return true if insn REG is an early clobber operand in alternative NALT. Negative NALT means that we don't know the current insn alternative. So assume the worst.
References lra_insn_reg::early_clobber_alts, LRA_NON_CLOBBERED_ALT, LRA_UNKNOWN_ALT, and TEST_BIT.
Referenced by process_bb_lives().
Return true if pseudo REGNO is in SET or all hard registers of REGNO in MODE are in SET.
References dead_set, end_hard_regno(), last, and sparseset_bit_p().
Referenced by process_bb_lives().
|
static |
Compress pseudo live ranges by removing program points where nothing happens. Complexity of many algorithms in LRA is linear function of program points number. To speed up the code we try to minimize the number of the program points here.
References bitmap_bit_p, bitmap_clear(), bitmap_ior(), bitmap_set_bit, EXECUTE_IF_SET_IN_BITMAP, free(), i, lra_assert, lra_dump_file, lra_live_max_point, lra_live_range_pool, lra_point_freq, lra_reg_info, map, MAX, max_reg_num(), max_regno, lra_live_range::next, NULL, r, and lra_live_range::start.
Referenced by compress_live_ranges().
Return TRUE if set A contains a pseudo register, otherwise, return FALSE.
References a, EXECUTE_IF_SET_IN_SPARSESET, and HARD_REGISTER_NUM_P.
Referenced by process_bb_lives().
|
static |
Mark pseudo REGNO as living or dying at program point POINT, depending on whether TYPE is a definition or a use. If this is the first reference to REGNO that we've encountered, then create a new live range for it.
References complete_info_p, create_live_range(), DEF_POINT, lra_live_range::finish, HARD_REGISTER_NUM_P, lra_assert, lra_get_regno_hard_regno(), lra_reg_info, NULL, pseudos_live, and sparseset_bit_p().
Referenced by process_bb_lives().
|
static |
Indexes of all function blocks.
|
static |
Bitmap with all hard regs.
Referenced by finish_live_solver(), initiate_live_solver(), live_con_fun_0(), live_con_fun_n(), live_trans_fun(), and lra_create_live_ranges_1().
|
static |
All basic block data are referred through the following array.
|
static |
Referenced by make_hard_regno_dead(), make_hard_regno_live(), mark_regno_dead(), mark_regno_live(), and process_bb_lives().
|
static |
The corresponding bitmaps of BB currently being processed.
Referenced by make_hard_regno_dead(), mark_regno_dead(), and process_bb_lives().
|
static |
A global flag whose true value says to build live ranges for all pseudos, otherwise the live ranges only for pseudos got memory is build. True value means also building copies and setting up hard register preferences. The complete info is necessary for assignment, rematerialization and spill to register passes. The complete info is not needed for the coalescing and spill to memory passes.
Referenced by lra_create_live_ranges_1(), process_bb_lives(), and update_pseudo_point().
|
static |
The insn data.
|
static |
Insn currently scanned.
|
static |
The insn static data.
|
static |
Referenced by clear_sparseset_regnos(), lra_create_live_ranges_1(), process_bb_lives(), and regnos_in_sparseset_p().
|
static |
Set of hard regs (except eliminable ones) currently live.
int lra_hard_reg_usage[FIRST_PSEUDO_REGISTER] |
Accumulated execution frequency of all references for each hard register.
Referenced by find_hard_regno_for_1(), lra_create_live_ranges_1(), lra_setup_reg_renumber(), process_bb_lives(), and setup_live_pseudos_and_spill_after_risky_transforms().
int lra_live_max_point |
Build live ranges for pseudos. Copyright (C) 2010-2025 Free Software Foundation, Inc. Contributed by Vladimir Makarov <vmakarov@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/>.
This file contains code to build pseudo live-ranges (analogous structures used in IRA, so read comments about the live-ranges there) and other info necessary for other passes to assign hard-registers to pseudos, coalesce the spilled pseudos, and assign stack memory slots to spilled pseudos.
Program points are enumerated by numbers from range 0..LRA_LIVE_MAX_POINT-1. There are approximately two times more program points than insns. Program points are places in the program where liveness info can be changed. In most general case (there are more complicated cases too) some program points correspond to places where input operand dies and other ones correspond to places where output operands are born.
Referenced by assign_spill_hard_regs(), create_live_range_start_chains(), init_live_reload_and_inheritance_pseudos(), init_lives(), lra_create_live_ranges_1(), and remove_some_program_points_and_update_live_ranges().
int lra_live_range_iter |
The number of the current live range pass.
Referenced by lra(), and lra_create_live_ranges_1().
|
static |
Pool for pseudo live ranges.
Referenced by copy_live_range(), create_live_range(), free_live_range_list(), lra_live_ranges_finish(), lra_merge_live_ranges(), and remove_some_program_points_and_update_live_ranges().
int* lra_point_freq |
The start of the above vector elements.
Referenced by lra_create_live_ranges_1(), next_program_point(), and remove_some_program_points_and_update_live_ranges().
|
static |
Vec containing execution frequencies of program points.
Referenced by lra_clear_live_ranges(), lra_create_live_ranges_1(), and next_program_point().
|
static |
Pseudos live at current point in the RTL scan.
Referenced by lra_create_live_ranges_1(), make_hard_regno_dead(), mark_pseudo_dead(), mark_pseudo_live(), process_bb_lives(), and update_pseudo_point().
|
static |
Pseudos probably living through calls and setjumps. As setjump is a call too, if a bit in PSEUDOS_LIVE_THROUGH_SETJUMPS is set up then the corresponding bit in PSEUDOS_LIVE_THROUGH_CALLS is set up too. These data are necessary for cases when only one subreg of a multi-reg pseudo is set up after a call. So we decide it is probably live when traversing bb backward. We are sure about living when we see its usage or definition of the pseudo.
Referenced by check_pseudos_live_through_calls(), lra_create_live_ranges_1(), and process_bb_lives().
|
static |
Referenced by check_pseudos_live_through_calls(), lra_create_live_ranges_1(), and process_bb_lives().
|
static |
Referenced by lra_create_live_ranges_1(), make_hard_regno_dead(), mark_pseudo_dead(), and process_bb_lives().
|
static |
Set of pseudos and hard registers start living/dying in the current insn. These sets are used to update REG_DEAD and REG_UNUSED notes in the insn.
Referenced by lra_create_live_ranges_1(), make_hard_regno_live(), mark_pseudo_live(), and process_bb_lives().
|
static |
Bitmap used for holding intermediate bitmap operation results.
|
static |
Set of pseudos and hard regs dead and unused in the current insn.
Referenced by lra_create_live_ranges_1(), and process_bb_lives().