GCC Middle and Back End API Reference
stmt.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "cfghooks.h"
#include "predict.h"
#include "memmodel.h"
#include "tm_p.h"
#include "optabs.h"
#include "regs.h"
#include "emit-rtl.h"
#include "pretty-print.h"
#include "diagnostic-core.h"
#include "fold-const.h"
#include "varasm.h"
#include "stor-layout.h"
#include "dojump.h"
#include "explow.h"
#include "stmt.h"
#include "expr.h"
#include "langhooks.h"
#include "cfganal.h"
#include "tree-cfg.h"
#include "dumpfile.h"
#include "builtins.h"
Include dependency graph for stmt.cc:

Data Structures

class  simple_case_node
 

Functions

static bool check_unique_operand_names (tree, tree, tree)
 
static charresolve_operand_name_1 (char *, tree, tree, tree)
 
rtx_insnlabel_rtx (tree label)
 
rtx_insnforce_label_rtx (tree label)
 
rtx_code_labeljump_target_rtx (tree label)
 
void emit_jump (rtx label)
 
void expand_label (tree label)
 
bool parse_output_constraint (const char **constraint_p, int operand_num, int ninputs, int noutputs, bool *allows_mem, bool *allows_reg, bool *is_inout)
 
bool parse_input_constraint (const char **constraint_p, int input_num, int ninputs, int noutputs, int ninout, const char *const *constraints, bool *allows_mem, bool *allows_reg)
 
static tree decl_overlaps_hard_reg_set_p (tree *declp, int *walk_subtrees, void *data)
 
tree tree_overlaps_hard_reg_set (tree decl, HARD_REG_SET *regs)
 
tree resolve_asm_operand_names (tree string, tree outputs, tree inputs, tree labels)
 
void expand_naked_return (void)
 
static void do_jump_if_equal (machine_mode mode, rtx op0, rtx op1, rtx_code_label *label, int unsignedp, profile_probability prob)
 
static profile_probability get_outgoing_edge_probs (basic_block bb)
 
static profile_probability conditional_probability (profile_probability target_prob, profile_probability base_prob)
 
static void emit_case_dispatch_table (tree index_expr, tree index_type, auto_vec< simple_case_node > &case_list, rtx default_label, edge default_edge, tree minval, tree maxval, tree range, basic_block stmt_bb)
 
void expand_case (gswitch *stmt)
 
void expand_sjlj_dispatch_table (rtx dispatch_index, vec< tree > dispatch_table)
 

Function Documentation

◆ check_unique_operand_names()

static bool check_unique_operand_names ( tree outputs,
tree inputs,
tree labels )
static
A subroutine of expand_asm_operands.  Check that all operand names
are unique.  Return true if so.  We rely on the fact that these names
are identifiers, and so have been canonicalized by get_identifier,
so all we need are pointer comparisons.   

References error(), failure, ggc_alloc(), i, NULL_TREE, simple_cst_equal(), TREE_CHAIN, TREE_PURPOSE, and TREE_STRING_POINTER.

Referenced by resolve_asm_operand_names().

◆ conditional_probability()

static profile_probability conditional_probability ( profile_probability target_prob,
profile_probability base_prob )
inlinestatic
Computes the conditional probability of jumping to a target if the branch
instruction is executed.
TARGET_PROB is the estimated probability of jumping to a target relative
to some basic block BB.
BASE_PROB is the probability of reaching the branch instruction relative
to the same basic block BB.   

References ggc_alloc().

Referenced by emit_case_dispatch_table().

◆ decl_overlaps_hard_reg_set_p()

static tree decl_overlaps_hard_reg_set_p ( tree * declp,
int * walk_subtrees,
void * data )
static
Return DECL iff there's an overlap between *REGS and DECL, where DECL
can be an asm-declared register.  Called via walk_tree.   

References DECL_HARD_REGISTER, DECL_RTL, GET_MODE, ggc_alloc(), NULL_TREE, overlaps_hard_reg_set_p(), REG_P, REGNO, TREE_CODE, TYPE_P, and VAR_P.

Referenced by tree_overlaps_hard_reg_set().

◆ do_jump_if_equal()

static void do_jump_if_equal ( machine_mode mode,
rtx op0,
rtx op1,
rtx_code_label * label,
int unsignedp,
profile_probability prob )
static
Generate code to jump to LABEL if OP0 and OP1 are equal in mode MODE. PROB
is the probability of jumping to LABEL.   

References do_compare_rtx_and_jump(), ggc_alloc(), NULL, and NULL_RTX.

Referenced by expand_sjlj_dispatch_table().

◆ emit_case_dispatch_table()

static void emit_case_dispatch_table ( tree index_expr,
tree index_type,
auto_vec< simple_case_node > & case_list,
rtx default_label,
edge default_edge,
tree minval,
tree maxval,
tree range,
basic_block stmt_bb )
static
Generate a dispatch tabler, switching on INDEX_EXPR and jumping to
one of the labels in CASE_LIST or to the DEFAULT_LABEL.
MINVAL, MAXVAL, and RANGE are the extrema and range of the case
labels in CASE_LIST. STMT_BB is the basic block containing the statement.

First, a jump insn is emitted.  First we try "casesi".  If that
fails, try "tablejump".   A target *must* have one of them (or both).

Then, a table with the target labels is emitted.

The process is unaware of the CFG.  The caller has to fix up
the CFG itself.  This is done in cfgexpand.cc.   

References build_int_cst(), CASE_VECTOR_PC_RELATIVE, compare_tree_int(), conditional_probability(), const0_rtx, emit_barrier(), emit_jump_table_data(), emit_label(), fold_build2, FOR_EACH_EDGE, gcc_assert, gen_label_rtx(), gen_rtvec_v(), get_outgoing_edge_probs(), ggc_alloc(), i, label_rtx(), simple_case_node::m_code_label, simple_case_node::m_high, simple_case_node::m_low, profile_probability::never(), optimize_insn_for_speed_p(), targetm, tree_to_shwi(), tree_to_uhwi(), try_casesi(), and try_tablejump().

Referenced by expand_case(), and expand_sjlj_dispatch_table().

◆ emit_jump()

◆ expand_case()

◆ expand_label()

void expand_label ( tree label)
Handle goto statements and the labels that they can go to.   
Specify the location in the RTL code of a label LABEL,
which is a LABEL_DECL tree node.

This is used for the kind of label that the user can jump to with a
goto statement, and for alternatives of a switch or case statement.
RTL labels generated for loops and conditionals don't go through here;
they are generated directly at the RTL level, by other functions below.

Note that this has nothing to do with defining label *names*.
Languages vary in how they do that and what that even means.   

References DECL_NAME, DECL_NONLOCAL, DECL_RTL, do_pending_stack_adjust(), emit_label(), expand_builtin_setjmp_receiver(), FORCED_LABEL, forced_labels, gen_rtx_INSN_LIST(), ggc_alloc(), IDENTIFIER_POINTER, jump_target_rtx(), LABEL_NAME, maybe_set_first_label_num(), nonlocal_goto_handler_labels, and NULL.

Referenced by expand_gimple_stmt_1().

◆ expand_naked_return()

void expand_naked_return ( void )
Generate RTL to return directly from the current function.
(That is, we bypass any return value.)   

References clear_pending_stack_adjust(), do_pending_stack_adjust(), emit_jump(), gen_label_rtx(), and naked_return_label.

Referenced by expand_builtin_return().

◆ expand_sjlj_dispatch_table()

void expand_sjlj_dispatch_table ( rtx dispatch_index,
vec< tree > dispatch_table )
Expand the dispatch to a short decrement chain if there are few cases
to dispatch to.  Likewise if neither casesi nor tablejump is available,
or if flag_jump_tables is set.  Otherwise, expand as a casesi or a
tablejump.  The index mode is always the mode of integer_type_node.
Trap if no case matches the index.

DISPATCH_INDEX is the index expression to switch on.  It should be a
memory or register operand.

DISPATCH_TABLE is a set of case labels.  The set should be sorted in
ascending order, be contiguous, starting with value 0, and contain only
single-valued case labels.   

References BLOCK_FOR_INSN(), build_int_cst(), CASE_HIGH, CASE_LABEL, CASE_LOW, CONST0_RTX, CONST1_RTX, copy_to_mode_reg(), do_jump_if_equal(), do_pending_stack_adjust(), emit_case_dispatch_table(), emit_label(), expand_builtin_trap(), force_expand_binop(), free_temp_slots(), gen_label_rtx(), get_last_insn(), ggc_alloc(), i, integer_type_node, jump_target_rtx(), make_tree(), NEXT_INSN(), NULL, NULL_TREE, OPTAB_DIRECT, reorder_insns(), targetm, TYPE_MODE, and profile_probability::uninitialized().

Referenced by sjlj_emit_dispatch_table().

◆ force_label_rtx()

rtx_insn * force_label_rtx ( tree label)
As above, but also put it on the forced-reference list of the
function that contains it.   

References decl_function_context(), forced_labels, gcc_assert, label_rtx(), and vec_safe_push().

Referenced by decode_addr_const().

◆ get_outgoing_edge_probs()

static profile_probability get_outgoing_edge_probs ( basic_block bb)
static
Return the sum of probabilities of outgoing edges of basic block BB.   

References FOR_EACH_EDGE, ggc_alloc(), profile_probability::never(), and basic_block_def::succs.

Referenced by emit_case_dispatch_table().

◆ jump_target_rtx()

rtx_code_label * jump_target_rtx ( tree label)
As label_rtx, but ensures (in check build), that returned value is
an existing label (i.e. rtx with code CODE_LABEL).   

References ggc_alloc(), and label_rtx().

Referenced by construct_init_block(), expand_case(), expand_goto(), expand_label(), expand_sjlj_dispatch_table(), label_rtx_for_bb(), and sjlj_emit_dispatch_table().

◆ label_rtx()

◆ parse_input_constraint()

bool parse_input_constraint ( const char ** constraint_p,
int input_num,
int ninputs,
int noutputs,
int ninout,
const char *const * constraints,
bool * allows_mem,
bool * allows_reg )

◆ parse_output_constraint()

bool parse_output_constraint ( const char ** constraint_p,
int operand_num,
int ninputs,
int noutputs,
bool * allows_mem,
bool * allows_reg,
bool * is_inout )
Parse the output constraint pointed to by *CONSTRAINT_P.  It is the
OPERAND_NUMth output operand, indexed from zero.  There are NINPUTS
inputs and NOUTPUTS outputs to this extended-asm.  Upon return,
*ALLOWS_MEM will be TRUE iff the constraint allows the use of a
memory operand.  Similarly, *ALLOWS_REG will be TRUE iff the
constraint allows the use of a register operand.  And, *IS_INOUT
will be true if the operand is read-write, i.e., if it is used as
an input as well as an output.  If *CONSTRAINT_P is not in
canonical form, it will be made canonical.  (Note that `+' will be
replaced with `=' as part of this process.)

Returns TRUE if all went well; FALSE if an error occurred.   

References error(), ggc_alloc(), ggc_alloc_string(), and warning().

Referenced by expand_asm_stmt(), find_func_aliases(), operands_scanner::get_asm_stmt_operands(), gimple_regimplify_operands(), gimplify_asm_expr(), walk_gimple_asm(), and walk_stmt_load_store_addr_ops().

◆ resolve_asm_operand_names()

tree resolve_asm_operand_names ( tree string,
tree outputs,
tree inputs,
tree labels )
Resolve the names of the operands in *POUTPUTS and *PINPUTS to numbers,
and replace the name expansions in STRING and in the constraints to
those numbers.  This is generally done in the front end while creating
the ASM_EXPR generic tree that eventually becomes the GIMPLE_ASM.   

References build_string(), check_unique_operand_names(), free(), ggc_alloc(), NULL, resolve_operand_name_1(), TREE_CHAIN, TREE_PURPOSE, TREE_STRING_POINTER, and TREE_VALUE.

◆ resolve_operand_name_1()

static char * resolve_operand_name_1 ( char * p,
tree outputs,
tree inputs,
tree labels )
static
A subroutine of resolve_operand_names.  P points to the '[' for a
potential named operand of the form [<name>].  In place, replace
the name and brackets with a number.  Return a pointer to the
balance of the string after substitution.   

References error(), gcc_assert, ggc_alloc(), identifier_to_locale(), NULL, TREE_CHAIN, TREE_PURPOSE, TREE_STRING_POINTER, and TREE_VALUE.

Referenced by resolve_asm_operand_names().

◆ tree_overlaps_hard_reg_set()

tree tree_overlaps_hard_reg_set ( tree decl,
HARD_REG_SET * regs )
If there is an overlap between *REGS and DECL, return the first overlap
found.   

References decl_overlaps_hard_reg_set_p(), NULL, and walk_tree.

Referenced by tree_conflicts_with_clobbers_p().