GCC Middle and Back End API Reference
dojump.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 "predict.h"
#include "memmodel.h"
#include "tm_p.h"
#include "optabs.h"
#include "emit-rtl.h"
#include "fold-const.h"
#include "stor-layout.h"
#include "dojump.h"
#include "explow.h"
#include "expr.h"
#include "langhooks.h"
#include "gt-dojump.h"
Include dependency graph for dojump.cc:

Functions

static bool prefer_and_bit_test (scalar_int_mode, int)
 
static void do_jump (tree, rtx_code_label *, rtx_code_label *, profile_probability)
 
static void do_jump_by_parts_greater (scalar_int_mode, tree, tree, int, rtx_code_label *, rtx_code_label *, profile_probability)
 
static void do_jump_by_parts_equality (scalar_int_mode, tree, tree, rtx_code_label *, rtx_code_label *, profile_probability)
 
static void do_compare_and_jump (tree, tree, enum rtx_code, enum rtx_code, rtx_code_label *, rtx_code_label *, profile_probability)
 
void init_pending_stack_adjust (void)
 
void discard_pending_stack_adjust (void)
 
void clear_pending_stack_adjust (void)
 
void do_pending_stack_adjust (void)
 
void save_pending_stack_adjust (saved_pending_stack_adjust *save)
 
void restore_pending_stack_adjust (saved_pending_stack_adjust *save)
 
static void do_jump_1 (enum tree_code code, tree op0, tree op1, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob)
 
static void do_jump_by_parts_greater_rtx (scalar_int_mode mode, int unsignedp, rtx op0, rtx op1, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob)
 
static void do_jump_by_parts_zero_rtx (scalar_int_mode mode, rtx op0, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob)
 
static void do_jump_by_parts_equality_rtx (scalar_int_mode mode, rtx op0, rtx op1, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob)
 
bool split_comparison (enum rtx_code code, machine_mode mode, enum rtx_code *code1, enum rtx_code *code2)
 
void jumpif (tree exp, rtx_code_label *label, profile_probability prob)
 
void jumpif_1 (enum tree_code code, tree op0, tree op1, rtx_code_label *label, profile_probability prob)
 
void jumpifnot (tree exp, rtx_code_label *label, profile_probability prob)
 
void jumpifnot_1 (enum tree_code code, tree op0, tree op1, rtx_code_label *label, profile_probability prob)
 
void do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp, machine_mode mode, rtx size, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob)
 
void do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp, tree val, machine_mode mode, rtx size, rtx_code_label *if_false_label, rtx_code_label *if_true_label, profile_probability prob)
 

Variables

static rtx and_reg
 
static rtx and_test
 
static rtx shift_test
 

Function Documentation

◆ clear_pending_stack_adjust()

void clear_pending_stack_adjust ( void )
When exiting from function, if safe, clear out any pending stack adjust
so the adjustment won't get done.

Note, if the current function calls alloca, then it must have a
frame pointer regardless of the value of flag_omit_frame_pointer.   

References cfun, discard_pending_stack_adjust(), and EXIT_IGNORE_STACK.

Referenced by expand_function_end(), expand_naked_return(), and expand_null_return_1().

◆ discard_pending_stack_adjust()

void discard_pending_stack_adjust ( void )
Discard any pending stack adjustment.  This avoid relying on the
RTL optimizers to remove useless adjustments when we know the
stack pointer value is dead.   

References pending_stack_adjust, and stack_pointer_delta.

Referenced by clear_pending_stack_adjust(), and emit_stack_restore().

◆ do_compare_and_jump()

static void do_compare_and_jump ( tree treeop0,
tree treeop1,
enum rtx_code signed_code,
enum rtx_code unsigned_code,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static
Generate code for a comparison expression EXP (including code to compute
the values to be compared) and a conditional jump to IF_FALSE_LABEL and/or
IF_TRUE_LABEL.  One of the labels can be NULL_RTX, in which case the
generated code will drop through.
SIGNED_CODE should be the rtx operation for this comparison for
signed data; UNSIGNED_CODE, likewise for use if data is unsigned.

We force a stack adjustment unless there are currently
things pushed on the stack that aren't yet used.   

References do_compare_rtx_and_jump(), emit_insn(), expand_normal(), expr_size(), FUNC_OR_METHOD_TYPE_P, gen_reg_rtx(), GET_MODE_BITSIZE(), NULL_RTX, POINTER_TYPE_P, SCALAR_INT_TYPE_MODE, targetm, TREE_CODE, TREE_TYPE, type(), TYPE_MODE, and TYPE_UNSIGNED.

Referenced by do_jump_1().

◆ do_compare_rtx_and_jump() [1/2]

◆ do_compare_rtx_and_jump() [2/2]

◆ do_jump()

static void do_jump ( tree exp,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static
Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
the result is zero, or IF_TRUE_LABEL if the result is one.
Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
meaning fall through in that case.

do_jump always does any pending stack adjust except when it does not
actually perform a jump.  An example where there is no jump
is when EXP is `(foo (), 0)' and IF_FALSE_LABEL is null.

PROB is probability of jump to if_true_label.   

References build2(), build_int_cstu(), CASE_CONVERT, compare_tree_int(), CONST0_RTX, CONVERT_EXPR_P, copy_to_reg(), do_compare_rtx_and_jump(), do_jump(), do_jump_1(), do_pending_stack_adjust(), emit_jump(), emit_label(), error_mark_node, exp(), expand_normal(), fold_convert, gcc_unreachable, gen_label_rtx(), GET_CODE, GET_MODE, have_insn_for(), HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT_1U, i, int_mode_for_size(), integer_onep(), integer_zerop(), profile_probability::invert(), NULL, NULL_RTX, optimize_insn_for_speed_p(), prefer_and_bit_test(), REG_P, SCALAR_INT_TYPE_MODE, shift, SUBREG_PROMOTED_VAR_P, TREE_CODE, tree_floor_log2(), TREE_INT_CST_LOW, TREE_OPERAND, TREE_SIDE_EFFECTS, TREE_TYPE, type(), lang_hooks_for_types::type_for_mode, TYPE_MODE, TYPE_PRECISION, TYPE_UNSIGNED, lang_hooks::types, profile_probability::uninitialized(), and XEXP.

Referenced by do_jump(), do_jump_1(), jumpif(), and jumpifnot().

◆ do_jump_1()

static void do_jump_1 ( enum tree_code code,
tree op0,
tree op1,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static

◆ do_jump_by_parts_equality()

static void do_jump_by_parts_equality ( scalar_int_mode mode,
tree treeop0,
tree treeop1,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static
Given an EQ_EXPR expression EXP for values too wide to be compared
with one insn, test the comparison and jump to the appropriate label.
MODE is the mode of the two operands.   

References do_jump_by_parts_equality_rtx(), and expand_normal().

Referenced by do_jump_1().

◆ do_jump_by_parts_equality_rtx()

static void do_jump_by_parts_equality_rtx ( scalar_int_mode mode,
rtx op0,
rtx op1,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static
Test for the equality of two RTX expressions OP0 and OP1 in mode MODE,
where MODE is an integer mode too wide to be compared with one insn.
Either (but not both) of IF_TRUE_LABEL and IF_FALSE_LABEL may be NULL_RTX
to indicate drop through.   

References const0_rtx, do_compare_rtx_and_jump(), do_jump_by_parts_zero_rtx(), emit_jump(), emit_label(), gen_label_rtx(), GET_MODE_SIZE(), i, NULL, NULL_RTX, operand_subword_force(), and word_mode.

Referenced by do_compare_rtx_and_jump(), and do_jump_by_parts_equality().

◆ do_jump_by_parts_greater()

static void do_jump_by_parts_greater ( scalar_int_mode mode,
tree treeop0,
tree treeop1,
int swap,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static
Given a comparison expression EXP for values too wide to be compared
with one insn, test the comparison and jump to the appropriate label.
The code of EXP is ignored; we always test GT if SWAP is 0,
and LT if SWAP is 1.  MODE is the mode of the two operands.   

References do_jump_by_parts_greater_rtx(), expand_normal(), TREE_TYPE, and TYPE_UNSIGNED.

Referenced by do_jump_1().

◆ do_jump_by_parts_greater_rtx()

static void do_jump_by_parts_greater_rtx ( scalar_int_mode mode,
int unsignedp,
rtx op0,
rtx op1,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static
Compare OP0 with OP1, word at a time, in mode MODE.
UNSIGNEDP says to do unsigned comparison.
Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise.   

References const0_rtx, do_compare_rtx_and_jump(), emit_jump(), emit_label(), gen_label_rtx(), GET_MODE_SIZE(), i, profile_probability::invert(), NULL, NULL_RTX, operand_subword_force(), and word_mode.

Referenced by do_compare_rtx_and_jump(), and do_jump_by_parts_greater().

◆ do_jump_by_parts_zero_rtx()

static void do_jump_by_parts_zero_rtx ( scalar_int_mode mode,
rtx op0,
rtx_code_label * if_false_label,
rtx_code_label * if_true_label,
profile_probability prob )
static
Jump according to whether OP0 is 0.  We assume that OP0 has an integer
mode, MODE, that is too wide for the available compare insns.  Either
Either (but not both) of IF_TRUE_LABEL and IF_FALSE_LABEL may be NULL
to indicate drop through.   

References const0_rtx, do_compare_rtx_and_jump(), emit_jump(), emit_label(), emit_move_insn(), expand_binop(), gen_label_rtx(), gen_reg_rtx(), GET_MODE_SIZE(), i, NULL, NULL_RTX, operand_subword_force(), OPTAB_WIDEN, and word_mode.

Referenced by do_jump_by_parts_equality_rtx().

◆ do_pending_stack_adjust()

◆ init_pending_stack_adjust()

void init_pending_stack_adjust ( void )
At the start of a function, record that we have no previously-pushed
arguments waiting to be popped.   

References pending_stack_adjust.

◆ jumpif()

void jumpif ( tree exp,
rtx_code_label * label,
profile_probability prob )
Generate code to evaluate EXP and jump to LABEL if the value is nonzero.
PROB is probability of jump to LABEL.   

References do_jump(), exp(), and NULL.

Referenced by expand_expr_real_1(), and store_constructor().

◆ jumpif_1()

void jumpif_1 ( enum tree_code code,
tree op0,
tree op1,
rtx_code_label * label,
profile_probability prob )
Similar to jumpif but dealing with exploded comparisons of the type
OP0 CODE OP1 .  LABEL and PROB are like in jumpif.   

References do_jump_1(), and NULL.

Referenced by expand_gimple_cond().

◆ jumpifnot()

void jumpifnot ( tree exp,
rtx_code_label * label,
profile_probability prob )
Generate code to evaluate EXP and jump to LABEL if the value is zero.
PROB is probability of jump to LABEL.   

References do_jump(), exp(), profile_probability::invert(), and NULL.

Referenced by expand_expr_real_1(), expand_expr_real_2(), and store_expr().

◆ jumpifnot_1()

void jumpifnot_1 ( enum tree_code code,
tree op0,
tree op1,
rtx_code_label * label,
profile_probability prob )
Similar to jumpifnot but dealing with exploded comparisons of the type
OP0 CODE OP1 .  LABEL and PROB are like in jumpifnot.   

References do_jump_1(), profile_probability::invert(), and NULL.

Referenced by expand_expr_real_2(), and expand_gimple_cond().

◆ prefer_and_bit_test()

static bool prefer_and_bit_test ( scalar_int_mode mode,
int bitnum )
static
Convert tree expression to rtl instructions, for GNU compiler.
   Copyright (C) 1988-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/>.   
Include expr.h after insn-config.h so we get HAVE_conditional_move.   
Compare the relative costs of "(X & (1 << BITNUM))" and "(X >> BITNUM) & 1",
where X is an arbitrary register of mode MODE.  Return true if the former
is preferred.   

References and_reg, and_test, const1_rtx, GEN_INT, gen_rtx_REG(), GET_MODE_PRECISION(), immed_wide_int_const(), LAST_VIRTUAL_REGISTER, NULL, optimize_insn_for_speed_p(), PUT_MODE(), rtx_cost(), wi::set_bit_in_zero(), shift_test, and XEXP.

Referenced by do_jump().

◆ restore_pending_stack_adjust()

void restore_pending_stack_adjust ( saved_pending_stack_adjust * save)

◆ save_pending_stack_adjust()

void save_pending_stack_adjust ( saved_pending_stack_adjust * save)
Remember pending_stack_adjust/stack_pointer_delta.
To be used around code that may call do_pending_stack_adjust (),
but the generated code could be discarded e.g. using delete_insns_since.   

References pending_stack_adjust, stack_pointer_delta, saved_pending_stack_adjust::x_pending_stack_adjust, and saved_pending_stack_adjust::x_stack_pointer_delta.

Referenced by emit_conditional_move(), and expand_call().

◆ split_comparison()

bool split_comparison ( enum rtx_code code,
machine_mode mode,
enum rtx_code * code1,
enum rtx_code * code2 )
Split a comparison into two others, the second of which has the other
"orderedness".  The first is always ORDERED or UNORDERED if MODE
does not honor NaNs (which means that it can be skipped in that case;
see do_compare_rtx_and_jump).

The two conditions are written in *CODE1 and *CODE2.  Return true if
the conditions must be ANDed, false if they must be ORed.   

References gcc_unreachable, and HONOR_NANS().

Referenced by do_compare_rtx_and_jump(), and emit_store_flag().

Variable Documentation

◆ and_reg

rtx and_reg
static
Used internally by prefer_and_bit_test.   

Referenced by prefer_and_bit_test().

◆ and_test

rtx and_test
static

Referenced by prefer_and_bit_test().

◆ shift_test

rtx shift_test
static

Referenced by prefer_and_bit_test().