GCC Middle and Back End API Reference
dojump.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "flags.h"
#include "function.h"
#include "insn-config.h"
#include "insn-attr.h"
#include "expr.h"
#include "optabs.h"
#include "langhooks.h"
#include "ggc.h"
#include "basic-block.h"
#include "tm_p.h"
#include "gt-dojump.h"
Include dependency graph for dojump.c:

Functions

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

Variables

static rtx and_reg
static rtx and_test
static rtx shift_test

Function Documentation

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.

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 cfun, discard_pending_stack_adjust(), and EXIT_IGNORE_STACK.

Referenced by discard_pending_stack_adjust().

static void do_compare_and_jump ( tree  treeop0,
tree  treeop1,
enum rtx_code  signed_code,
enum rtx_code  unsigned_code,
rtx  if_false_label,
rtx  if_true_label,
int  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.

Don't crash if the comparison was erroneous.

     op0 might have been replaced by promoted constant, in which
     case the type of second argument should be used.   
void do_compare_rtx_and_jump ( rtx  op0,
rtx  op1,
enum rtx_code  code,
int  unsignedp,
enum machine_mode  mode,
rtx  size,
rtx  if_false_label,
rtx  if_true_label,
int  prob 
)

Like do_compare_and_jump but expects the values to compare as two rtx's. The decision as to signed or unsigned comparison must be made by the caller.

If MODE is BLKmode, SIZE is an RTX giving the size of the objects being compared.

 Reverse the comparison if that is safe and we want to jump if it is
 false.  Also convert to the reverse comparison if the target can
 implement it.   
     Canonicalize to UNORDERED for the libcall.   
 If one operand is constant, make it the second one.  Only do this
 if the other operand is not constant as well.   
              Never split ORDERED and UNORDERED.
              These must be implemented.   
              Split a floating-point comparison if
              we can jump on other conditions...   
                  ... or if there is no libcall for it.   
         If there are no NaNs, the first comparison should always fall
         through.   
                 If we only jump if true, just bypass the second jump.   

References const0_rtx, CONST0_RTX, and emit_jump().

Referenced by do_jump_by_parts_zero_rtx(), and expand_return().

void do_jump ( )

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, or -1 if unknown.

     If we are narrowing the operand, we have to do the compare in the
     narrower mode.   
     These cannot change zero->nonzero or vice versa.   
     Lowered by gimplify.c.   
     Nonzero iff operands of minus differ.   
     FALLTHRU  
     fold_single_bit_test() converts (X & (1 << C)) into (X >> C) & 1.
     See if the former is preferred for jump tests and restore it
     if so.   
         Strip narrowing integral type conversions.   
         "exp0 ^ 1" inverts the sense of the single bit test.   
     If we are AND'ing with a small constant, do this comparison in the
     smallest type that fits.  If the machine doesn't have comparisons
     that small, it will be converted back to the wider comparison.
     This helps if we are testing the sign bit of a narrower object.
     combine can't do this for us because it can't know whether a
     ZERO_EXTRACT or a compare in a smaller mode exists, but we do.   
     Boolean comparisons can be compiled as TRUTH_AND_EXPR.   
     High branch cost, expand as the bitwise AND of the conditions.
     Do the same if the RHS has side effects, because we're effectively
     turning a TRUTH_AND_EXPR into a TRUTH_ANDIF_EXPR.   
     High branch cost, expand as the bitwise OR of the conditions.
     Do the same if the RHS has side effects, because we're effectively
     turning a TRUTH_OR_EXPR into a TRUTH_ORIF_EXPR.   
     Fall through and generate the normal code.   
     The RTL optimizers prefer comparisons against pseudos.   
         Compare promoted variables in their promoted mode.   

Referenced by jumpifnot_1().

void do_jump_1 ( enum tree_code  code,
tree  op0,
tree  op1,
rtx  if_false_label,
rtx  if_true_label,
int  prob 
)

Subroutine of do_jump, dealing with exploded comparisons of the type OP0 CODE OP1 . IF_FALSE_LABEL and IF_TRUE_LABEL like in do_jump. PROB is probability of jump to if_true_label, or -1 if unknown.

       Spread the probability that the expression is false evenly between
       the two conditions. So the first condition is false half the total
       probability of being false. The second condition is false the other
       half of the total probability of being false, so its jump has a false
       probability of half the total, relative to the probability we
       reached it (i.e. the first condition was true).   
           Get the probability that each jump below is true.   
       Spread the probability evenly between the two conditions. So
       the first condition has half the total probability of being true.
       The second condition has the other half of the total probability,
       so its jump has a probability of half the total, relative to
       the probability we reached it (i.e. the first condition was false).   
static void do_jump_by_parts_equality ( tree  treeop0,
tree  treeop1,
rtx  if_false_label,
rtx  if_true_label,
int  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.

static void do_jump_by_parts_equality_rtx ( enum machine_mode  mode,
rtx  op0,
rtx  op1,
rtx  if_false_label,
rtx  if_true_label,
int  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.

static void do_jump_by_parts_greater ( tree  treeop0,
tree  treeop1,
int  swap,
rtx  if_false_label,
rtx  if_true_label,
int  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.

static void do_jump_by_parts_greater_rtx ( enum machine_mode  mode,
int  unsignedp,
rtx  op0,
rtx  op1,
rtx  if_false_label,
rtx  if_true_label,
int  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.

 Deal with the special case 0 > x: only one comparison is necessary and
 we reverse it to avoid jumping to the drop-through label.   
 Compare a word at a time, high order first.   
     All but high-order word must be compared as unsigned.   
     Emit only one comparison for 0.  Do not emit the last cond jump.   
     Consider lower words only if these are equal.   

References operand_subword_force().

static void do_jump_by_parts_zero_rtx ( enum machine_mode  mode,
rtx  op0,
rtx  if_false_label,
rtx  if_true_label,
int  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_RTX to indicate drop through.

The fastest way of doing this comparison on almost any machine is to "or" all the words and compare the result. If all have to be loaded from memory and this is a very wide item, it's possible this may be slower, but that's highly unlikely.

 If we couldn't do the "or" simply, do this with a series of compares.   

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

void do_pending_stack_adjust ( void  )

Pop any previously-pushed arguments that have not been popped yet.

Referenced by build_libfunc_function(), emit_jump(), expand_computed_goto(), expand_float(), and have_sub2_insn().

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, and stack_pointer_delta.

static int inv ( )
inlinestatic

Invert probability if there is any. -1 stands for unknown.

Referenced by find_invariant_insn(), and gain_for_invariant().

void jumpif ( )

Generate code to evaluate EXP and jump to LABEL if the value is nonzero.

void jumpif_1 ( )
void jumpifnot ( )

Expand conditional expressions. Generate code to evaluate EXP and jump to LABEL if the value is zero. LABEL is an rtx of code CODE_LABEL, in this function and all the functions here.

void jumpifnot_1 ( )

References do_jump(), and NULL_RTX.

static bool prefer_and_bit_test ( enum  machine_mode,
int   
)
static

Convert tree expression to rtl instructions, for GNU compiler. Copyright (C) 1988-2013 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.

static bool prefer_and_bit_test ( )
static

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.

     Set up rtxes for the two variations.  Use NULL as a placeholder
     for the BITNUM-based constants.   
     Change the mode of the previously-created rtxes.   
 Fill in the integers.   
bool split_comparison ( enum rtx_code  code,
enum 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.

Do not turn a trapping comparison into a non-trapping one.

Referenced by emit_cstore().


Variable Documentation

rtx and_reg
static

Used internally by prefer_and_bit_test.

rtx and_test
static
rtx shift_test
static