GCC Middle and Back End API Reference
ira-conflicts.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "predict.h"
#include "memmodel.h"
#include "tm_p.h"
#include "insn-config.h"
#include "regs.h"
#include "ira.h"
#include "ira-int.h"
#include "sparseset.h"
#include "addresses.h"
Include dependency graph for ira-conflicts.cc:

Macros

#define OBJECTS_CONFLICT_P(C1, C2)
 
#define REG_SUBREG_P(x)    (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))))
 

Functions

static void record_object_conflict (ira_object_t obj1, ira_object_t obj2)
 
static bool build_conflict_bit_table (void)
 
static bool allocnos_conflict_for_copy_p (ira_allocno_t a1, ira_allocno_t a2)
 
static rtx go_through_subreg (rtx x, int *offset)
 
static int get_freq_for_shuffle_copy (int freq)
 
static bool process_regs_for_copy (rtx reg1, rtx reg2, bool constraint_p, rtx_insn *insn, int freq, bool single_input_op_has_cstr_p=true)
 
static bool can_use_same_reg_p (rtx_insn *insn, int output, int input)
 
static void process_reg_shuffles (rtx_insn *insn, rtx reg, int op_num, int freq, bool *bound_p)
 
static void add_insn_allocno_copies (rtx_insn *insn)
 
static void add_copies (ira_loop_tree_node_t loop_tree_node)
 
static void propagate_copies (void)
 
static void build_object_conflicts (ira_object_t obj)
 
static void build_conflicts (void)
 
static void print_hard_reg_set (FILE *file, const char *title, HARD_REG_SET set)
 
static void print_allocno_conflicts (FILE *file, bool reg_p, ira_allocno_t a)
 
static void print_conflicts (FILE *file, bool reg_p)
 
void ira_debug_conflicts (bool reg_p)
 
void ira_build_conflicts (void)
 

Variables

static IRA_INT_TYPE ** conflicts
 
static ira_object_tcollected_conflict_objects
 

Macro Definition Documentation

◆ OBJECTS_CONFLICT_P

#define OBJECTS_CONFLICT_P ( C1,
C2 )
Value:
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
static IRA_INT_TYPE ** conflicts
Definition ira-conflicts.cc:46
#define TEST_MINMAX_SET_BIT(R, I, MIN, MAX)
Definition ira-int.h:721
#define OBJECT_MAX(O)
Definition ira-int.h:538
#define OBJECT_MIN(O)
Definition ira-int.h:537
#define OBJECT_CONFLICT_ID(O)
Definition ira-int.h:539
Macro to test a conflict of C1 and C2 in `conflicts'.   

Referenced by allocnos_conflict_for_copy_p().

◆ REG_SUBREG_P

#define REG_SUBREG_P ( x)     (REG_P (x) || (GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x))))
Check that X is REG or SUBREG of REG.   

Referenced by add_insn_allocno_copies(), process_reg_shuffles(), and process_regs_for_copy().

Function Documentation

◆ add_copies()

static void add_copies ( ira_loop_tree_node_t loop_tree_node)
static
Add copies originated from BB given by LOOP_TREE_NODE.   

References add_insn_allocno_copies(), ira_loop_tree_node::bb, FOR_BB_INSNS, NONDEBUG_INSN_P, and NULL.

Referenced by ira_build_conflicts().

◆ add_insn_allocno_copies()

static void add_insn_allocno_copies ( rtx_insn * insn)
static
Process INSN and create allocno copies if necessary.  For example,
it might be because INSN is a pseudo-register move or INSN is two
operand insn.   

References BLOCK_FOR_INSN(), find_reg_note(), get_freq_for_shuffle_copy(), ggc_alloc(), i, ira_get_dup_out_num(), ira_setup_alts(), recog_data_d::n_operands, NULL, NULL_RTX, recog_data_d::operand, process_reg_shuffles(), process_regs_for_copy(), recog_data, REG_FREQ_FROM_BB, REG_P, REG_SUBREG_P, SET_DEST, SET_SRC, side_effects_p(), single_set(), and SUBREG_REG.

Referenced by add_copies().

◆ allocnos_conflict_for_copy_p()

static bool allocnos_conflict_for_copy_p ( ira_allocno_t a1,
ira_allocno_t a2 )
static
Return true iff allocnos A1 and A2 cannot be allocated to the same
register due to conflicts.   

References ALLOCNO_OBJECT, ggc_alloc(), and OBJECTS_CONFLICT_P.

Referenced by process_regs_for_copy(), and propagate_copies().

◆ build_conflict_bit_table()

◆ build_conflicts()

static void build_conflicts ( void )
static
Build conflict vectors or bit conflict vectors (whatever is more
profitable) of all allocnos from the conflict table.   

References a, ALLOCNO_CAP, ALLOCNO_NEXT_REGNO_ALLOCNO, ALLOCNO_NUM_OBJECTS, ALLOCNO_OBJECT, build_object_conflicts(), collected_conflict_objects, gcc_assert, ggc_alloc(), i, ira_allocate(), ira_free(), ira_objects_num, ira_regno_allocno_map, max_reg_num(), and NULL.

Referenced by ira_build_conflicts().

◆ build_object_conflicts()

◆ can_use_same_reg_p()

static bool can_use_same_reg_p ( rtx_insn * insn,
int output,
int input )
static
Return true if output operand OUTPUT and input operand INPUT of
INSN can use the same register class for at least one alternative.
INSN is already described in recog_data and recog_op_alt.   

References get_preferred_alternatives(), ggc_alloc(), ira_reg_class_intersect, recog_data_d::n_alternatives, recog_data_d::n_operands, recog_data, recog_op_alt, and TEST_BIT.

Referenced by process_reg_shuffles().

◆ get_freq_for_shuffle_copy()

static int get_freq_for_shuffle_copy ( int freq)
static
Return the recomputed frequency for this shuffle copy or its similar
case, since it's not for a real move insn, make it smaller.   

Referenced by add_insn_allocno_copies(), and process_regs_for_copy().

◆ go_through_subreg()

static rtx go_through_subreg ( rtx x,
int * offset )
static
Return X if X is a REG, otherwise it should be SUBREG of REG and
the function returns the reg in this case.  *OFFSET will be set to
0 in the first case or the regno offset in the first case.   

References gcc_unreachable, GET_CODE, GET_MODE, ggc_alloc(), ira_assert, offset, REG_P, REGMODE_NATURAL_SIZE, REGNO, SUBREG_BYTE, SUBREG_REG, and subreg_regno_offset().

Referenced by process_regs_for_copy().

◆ ira_build_conflicts()

◆ ira_debug_conflicts()

void ira_debug_conflicts ( bool reg_p)
Print information about allocno or only regno (if REG_P) conflicts
to stderr.   

References ggc_alloc(), and print_conflicts().

◆ print_allocno_conflicts()

◆ print_conflicts()

static void print_conflicts ( FILE * file,
bool reg_p )
static
Print information about allocno or only regno (if REG_P) conflicts
to FILE.   

References a, FOR_EACH_ALLOCNO, ggc_alloc(), and print_allocno_conflicts().

Referenced by ira_build_conflicts(), and ira_debug_conflicts().

◆ print_hard_reg_set()

static void print_hard_reg_set ( FILE * file,
const char * title,
HARD_REG_SET set )
static
Print hard reg set SET with TITLE to FILE.   

References end(), ggc_alloc(), i, and TEST_HARD_REG_BIT.

Referenced by print_allocno_conflicts().

◆ process_reg_shuffles()

static void process_reg_shuffles ( rtx_insn * insn,
rtx reg,
int op_num,
int freq,
bool * bound_p )
static
Process all of the output registers of the current insn (INSN) which
are not bound (BOUND_P) and the input register REG (its operand number
OP_NUM) which dies in the insn as if there were a move insn between
them with frequency FREQ.   

References can_use_same_reg_p(), recog_data_d::constraints, gcc_assert, ggc_alloc(), i, recog_data_d::n_operands, NULL, OP_OUT, recog_data_d::operand, recog_data_d::operand_type, process_regs_for_copy(), recog_data, and REG_SUBREG_P.

Referenced by add_insn_allocno_copies().

◆ process_regs_for_copy()

static bool process_regs_for_copy ( rtx reg1,
rtx reg2,
bool constraint_p,
rtx_insn * insn,
int freq,
bool single_input_op_has_cstr_p = true )
static
Process registers REG1 and REG2 in move INSN with execution
frequency FREQ.  The function also processes the registers in a
potential move insn (INSN == NULL in this case) with frequency
FREQ.  The function can modify hard register costs of the
corresponding allocnos or create a copy involving the corresponding
allocnos.  The function does nothing if the both registers are hard
registers.  When nothing is changed, the function returns FALSE.
SINGLE_INPUT_OP_HAS_CSTR_P is only meaningful when constraint_p
is true, see function ira_get_dup_out_num for its meaning.   

References a, ALLOCNO_CLASS, ALLOCNO_CLASS_COST, ALLOCNO_CONFLICT_HARD_REG_COSTS, ALLOCNO_HARD_REG_COSTS, ALLOCNO_MODE, allocnos_conflict_for_copy_p(), bitmap_set_bit, gcc_assert, get_freq_for_shuffle_copy(), GET_MODE_PRECISION(), ggc_alloc(), go_through_subreg(), HARD_REGISTER_P, IN_RANGE, ira_add_allocno_copy(), ira_add_allocno_pref(), ira_allocate_and_set_costs(), ira_class_hard_reg_index, ira_curr_loop_tree_node, ira_curr_regno_allocno_map, ira_init_register_move_cost_if_necessary(), ira_parent_or_cap_allocno(), ira_reg_class_max_nregs, ira_register_move_cost, ira_loop_tree_node::local_copies, NULL, NULL_RTX, reg_class_size, REG_P, REG_SUBREG_P, and REGNO.

Referenced by add_insn_allocno_copies(), and process_reg_shuffles().

◆ propagate_copies()

static void propagate_copies ( void )
static
Propagate copies the corresponding allocnos on upper loop tree
level.   

References ALLOCNO_LOOP_TREE_NODE, allocnos_conflict_for_copy_p(), FOR_EACH_COPY, ggc_alloc(), ira_add_allocno_copy(), ira_assert, ira_loop_tree_root, ira_parent_or_cap_allocno(), and NULL.

Referenced by ira_build_conflicts().

◆ record_object_conflict()

static void record_object_conflict ( ira_object_t obj1,
ira_object_t obj2 )
static
Record a conflict between objects OBJ1 and OBJ2.  If necessary,
canonicalize the conflict by recording it for lower-order subobjects
of the corresponding allocnos.   

References ALLOCNO_OBJECT, conflicts, ggc_alloc(), OBJECT_ALLOCNO, OBJECT_CONFLICT_ID, OBJECT_MAX, OBJECT_MIN, OBJECT_SUBWORD, and SET_MINMAX_SET_BIT.

Referenced by build_conflict_bit_table().

Variable Documentation

◆ collected_conflict_objects

ira_object_t* collected_conflict_objects
static
Array used to collect all conflict allocnos for given allocno.   

Referenced by build_conflicts(), and build_object_conflicts().

◆ conflicts

IRA_INT_TYPE** conflicts
static
IRA conflict builder.
   Copyright (C) 2006-2024 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 responsible for allocno conflict creation,
allocno copy creation and allocno info accumulation on upper level
regions.   
ira_allocnos_num array of arrays of bits, recording whether two
allocno's conflict (can't go in the same hardware register).

Some arrays will be used as conflict bit vector of the
corresponding allocnos see function build_object_conflicts.   

Referenced by build_conflict_bit_table(), build_object_conflicts(), initialize_conflict_count(), ira_build_conflicts(), ira_propagate_hard_reg_costs(), ira_total_conflict_hard_regs(), move_spill_restore(), oacc_do_neutering(), record_object_conflict(), and sort_coalesce_list().