GCC Middle and Back End API Reference
stmt.c File Reference

Data Structures

struct  case_node

Typedefs

typedef struct case_node case_node
typedef struct case_nodecase_node_ptr

Functions

basic_block label_to_block_fn (struct function *, tree)
static int n_occurrences (int, const char *)
static bool tree_conflicts_with_clobbers_p (tree, HARD_REG_SET *)
static bool check_operand_nalternatives (tree, tree)
static bool check_unique_operand_names (tree, tree, tree)
static char * resolve_operand_name_1 (char *, tree, tree, tree)
static void expand_null_return_1 (void)
static void expand_value_return (rtx)
static void balance_case_nodes (case_node_ptr *, case_node_ptr)
static int node_has_low_bound (case_node_ptr, tree)
static int node_has_high_bound (case_node_ptr, tree)
static int node_is_bounded (case_node_ptr, tree)
static void emit_case_nodes (rtx, case_node_ptr, rtx, int, tree)
rtx label_rtx ()
rtx force_label_rtx ()
void emit_jump ()
void expand_computed_goto ()
void expand_label ()
void expand_goto ()
static int n_occurrences ()
static void expand_asm_loc ()
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 ()
static bool tree_conflicts_with_clobbers_p ()
static void expand_asm_operands (tree string, tree outputs, tree inputs, tree clobbers, tree labels, basic_block fallthru_bb, int vol, location_t locus)
void expand_asm_stmt ()
static bool check_operand_nalternatives ()
static bool check_unique_operand_names ()
tree resolve_asm_operand_names ()
static char * resolve_operand_name_1 ()
void expand_null_return ()
void expand_naked_return ()
static void expand_value_return ()
void expand_return ()
rtx expand_stack_save ()
void expand_stack_restore ()
static void do_jump_if_equal (enum machine_mode mode, rtx op0, rtx op1, rtx label, int unsignedp, int prob)
static struct case_nodeadd_case_node (struct case_node *head, tree low, tree high, tree label, int prob, alloc_pool case_node_pool)
static void dump_case_nodes (FILE *f, struct case_node *root, int indent_step, int indent_level)
static unsigned int case_values_threshold ()
static bool expand_switch_as_decision_tree_p (tree range, unsigned int uniq, unsigned int count)
static void emit_case_decision_tree (tree index_expr, tree index_type, struct case_node *case_list, rtx default_label, int default_prob)
static int get_outgoing_edge_probs ()
static int conditional_probability ()
static void emit_case_dispatch_table (tree index_expr, tree index_type, struct case_node *case_list, rtx default_label, tree minval, tree maxval, tree range, basic_block stmt_bb)
static void reset_out_edges_aux ()
static void compute_cases_per_edge ()
void expand_case ()
void expand_sjlj_dispatch_table (rtx dispatch_index, vec< tree > dispatch_table)
static void balance_case_nodes ()
static int node_has_low_bound ()
static int node_has_high_bound ()
static int node_is_bounded ()

Typedef Documentation

typedef struct case_node case_node
typedef struct case_node* case_node_ptr

Function Documentation

static struct case_node* add_case_node ( struct case_node head,
tree  low,
tree  high,
tree  label,
int  prob,
alloc_pool  case_node_pool 
)
staticread
   Do the insertion of a case label into case_list.  The labels are
   fed to us in descending order from the sorted vector of case labels used
   in the tree part of the middle end.  So the list we construct is
   sorted in ascending order.
   
   LABEL is the case label to be inserted. LOW and HIGH are the bounds
   against which the index is compared to jump to LABEL and PROB is the
   estimated probability LABEL is reached from the switch statement.  
     Add this label to the chain.  
static void balance_case_nodes ( case_node_ptr ,
case_node_ptr   
)
static

Referenced by dump_case_nodes().

static void balance_case_nodes ( )
static
   Take an ordered list of case nodes
   and transform them into a near optimal binary tree,
   on the assumption that any target code selection value is as
   likely as any other.

   The transformation is performed by splitting the ordered
   list into two equal sections plus a pivot.  The parts are
   then attached to the pivot as left and right branches.  Each
   branch is then transformed recursively.  
         Count the number of entries on branch.  Also count the ranges.  
             Split this list if it is long enough for that to help.  
             If there are just three nodes, split at the middle one.  
                 Find the place in the list that bisects the list's total cost,
                 where ranges count as 2.
                 Here I gets half the total cost.  
                     Skip nodes while their cost does not reach that amount.  
             Optimize each of the two split parts.  
             Else leave this branch as one level,
             but fill in `parent' fields.  
static unsigned int case_values_threshold ( )
static
   Return the smallest number of different values for which it is best to use a
   jump-table instead of a tree of conditional branches.  

References ceil_log2(), dump_case_nodes(), and dump_file.

static bool check_operand_nalternatives ( tree  ,
tree   
)
static
static bool check_operand_nalternatives ( )
static
   A subroutine of expand_asm_operands.  Check that all operands have
   the same number of alternatives.  Return true if so.  
static bool check_unique_operand_names ( tree  ,
tree  ,
tree   
)
static
static bool check_unique_operand_names ( )
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.  
static void compute_cases_per_edge ( )
inlinestatic
   Compute the number of case labels that correspond to each outgoing edge of
   STMT. Record this information in the aux field of the edge.  
static int conditional_probability ( )
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 edge_def::probability, and basic_block_def::succs.

Referenced by node_has_low_bound().

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 error(), and tree_overlaps_hard_reg_set().

static void do_jump_if_equal ( enum machine_mode  mode,
rtx  op0,
rtx  op1,
rtx  label,
int  unsignedp,
int  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.  
static void dump_case_nodes ( FILE *  f,
struct case_node root,
int  indent_step,
int  indent_level 
)
static
static void emit_case_decision_tree ( tree  index_expr,
tree  index_type,
struct case_node case_list,
rtx  default_label,
int  default_prob 
)
static
   Generate a decision tree, switching on INDEX_EXPR and jumping to
   one of the labels in CASE_LIST or to the DEFAULT_LABEL.
   DEFAULT_PROB is the estimated probability that it jumps to
   DEFAULT_LABEL.
   
   We generate a binary decision tree to select the appropriate target
   code.  This is done as follows:

     If the index is a short or char that we do not have
     an insn to handle comparisons directly, convert it to
     a full integer now, rather than letting each comparison
     generate the conversion.

     Load the index into a register.

     The list of cases is rearranged into a binary tree,
     nearly optimal assuming equal probability for each case.

     The tree is transformed into RTL, eliminating redundant
     test conditions at the same time.

     If program flow could reach the end of the decision tree
     an unconditional jump to the default code is emitted.

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

References build_int_cst().

static void emit_case_dispatch_table ( tree  index_expr,
tree  index_type,
struct case_node case_list,
rtx  default_label,
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.c.  
         Index jumptables from zero for suitable values of minval to avoid
         a subtraction.  For the rationale see:
         "http://gcc.gnu.org/ml/gcc-patches/2001-10/msg01234.html".  
     Get table of labels to jump to, in order of case index.  
         Compute the low and high bounds relative to the minimum
         value since that should fit in a HOST_WIDE_INT while the
         actual values may not.  
     Fill in the gaps with the default.  We may have gaps at
     the beginning if we tried to avoid the minval subtraction,
     so substitute some label even if the default label was
     deemed unreachable.  
         There is at least one entry in the jump table that jumps
         to default label. The default label can either be reached
         through the indirect jump or the direct conditional jump
         before that. Split the probability of reaching the
         default label among these two jumps.  
     We have altered the probability of the default edge. So the probabilities
     of all other edges need to be adjusted so that it sums up to
     REG_BR_PROB_BASE.  
     Output the table.  
     Record no drop-through after the table.  
static void emit_case_nodes ( rtx  index,
case_node_ptr  node,
rtx  default_label,
int  default_prob,
tree  index_type 
)
static
   Emit step-by-step code to select a case for the value of INDEX.
   The thus generated decision tree follows the form of the
   case-node binary tree NODE, whose nodes represent test conditions.
   INDEX_TYPE is the type of the index of the switch.

   Care is taken to prune redundant tests from the decision tree
   by detecting any boundary conditions already checked by
   emitted rtx.  (See node_has_high_bound, node_has_low_bound
   and node_is_bounded, above.)

   Where the test conditions can be shown to be redundant we emit
   an unconditional jump to the target code.  As a further
   optimization, the subordinates of a tree node are examined to
   check for bounded nodes.  In this case conditional and/or
   unconditional jumps as a result of the boundary check for the
   current node are arranged to target the subordinates associated
   code for out of bound conditions on the current node.

   We can assume that when control reaches the code generated here,
   the index value has already been compared with the parents
   of this node, and determined to be on the same side of each parent
   as this node is.  Thus, if this node tests for the value 51,
   and a parent tested for 52, we don't need to consider
   the possibility of a value greater than 51.  If another parent
   tests for the value 50, then this node need not test anything.  
     If INDEX has an unsigned type, we must make unsigned branches.  
     Handle indices detected as constant during RTL expansion.  
     See if our parents have already tested everything for us.
     If they have, emit an unconditional jump for this node.  
         Node is single valued.  First see if the index expression matches
         this node and then check our children, if any.  
         Since this case is taken at this point, reduce its weight from
         subtree_weight.  
             This node has children on both sides.
             Dispatch to one side or the other
             by comparing the index value with this node's value.
             If one subtree is bounded, check that one first,
             so we can avoid real branches in the tree.  
             If both children are single-valued cases with no
             children, finish up all the work.  This way, we can save
             one ordered comparison.  
                 Neither node is bounded.  First distinguish the two sides;
                 then emit the code for one side at a time.  
                 See if the value matches what the right hand side
                 wants.  
                 See if the value matches what the left hand side
                 wants.  
                 Neither node is bounded.  First distinguish the two sides;
                 then emit the code for one side at a time.  
                 The default label could be reached either through the right
                 subtree or the left subtree. Divide the probability
                 equally.  
                 See if the value is on the right.  
                 Value must be on the left.
                 Handle the left-hand subtree.  
                 If left-hand subtree does nothing,
                 go to default.  
                 Code branches here for the right-hand subtree.  
             Here we have a right child but no left so we issue a conditional
             branch to default and process the right child.

             Omit the conditional branch to default if the right child
             does not have any children and is single valued; it would
             cost too much space to save so little time.  
                 We cannot process node->right normally
                 since we haven't ruled out the numbers less than
                 this node's value.  So handle node->right explicitly.  
             Just one subtree, on the left.  
                 We cannot process node->left normally
                 since we haven't ruled out the numbers less than
                 this node's value.  So handle node->left explicitly.  
         Node is a range.  These cases are very similar to those for a single
         value, except that we do not start by testing whether this node
         is the one to branch to.  
             Node has subtrees on both sides.
             If the right-hand subtree is bounded,
             test for it first, since we can go straight there.
             Otherwise, we need to make a branch in the control structure,
             then handle the two subtrees.  
                 Right hand node is fully bounded so we can eliminate any
                 testing and branch directly to the target code.  
                 Right hand node requires testing.
                 Branch to a label where we will handle it later.  
             Value belongs to this node or to the left-hand subtree.  
             Handle the left-hand subtree.  
             If right node had to be handled later, do that now.  
                 If the left-hand subtree fell through,
                 don't let it fall into the right-hand subtree.  
             Deal with values to the left of this node,
             if they are possible.  
             Value belongs to this node or to the right-hand subtree.  
             Deal with values to the right of this node,
             if they are possible.  
             Value belongs to this node or to the left-hand subtree.  
             Node has no children so we check low and high bounds to remove
             redundant tests.  Only one of the bounds can exist,
             since otherwise this node is bounded--a case tested already.  
                 Widen LOW and HIGH to the same width as INDEX.  
                 Instead of doing two branches, emit one unsigned branch for
                 (index-low) > (high-low).  

Referenced by node_has_low_bound().

void emit_jump ( )
   Add an unconditional jump to LABEL as the next sequential instruction.  

References do_pending_stack_adjust(), emit_indirect_jump(), and expand_normal().

static void expand_asm_loc ( )
static
   Generate RTL for an asm statement (explicit assembler code).
   STRING is a STRING_CST node containing the assembler code text,
   or an ADDR_EXPR containing a STRING_CST.  VOL nonzero means the
   insn is volatile; don't optimize it.  
static void expand_asm_operands ( tree  string,
tree  outputs,
tree  inputs,
tree  clobbers,
tree  labels,
basic_block  fallthru_bb,
int  vol,
location_t  locus 
)
static
   Generate RTL for an asm statement with arguments.
   STRING is the instruction template.
   OUTPUTS is a list of output arguments (lvalues); INPUTS a list of inputs.
   Each output or input has an expression in the TREE_VALUE and
   a tree list in TREE_PURPOSE which in turn contains a constraint
   name in TREE_VALUE (or NULL_TREE) and a constraint string
   in TREE_PURPOSE.
   CLOBBERS is a list of STRING_CST nodes each naming a hard register
   that is clobbered by this insn.

   LABELS is a list of labels, and if LABELS is non-NULL, FALLTHRU_BB
   should be the fallthru basic block of the asm goto.

   Not all kinds of lvalue that may appear in OUTPUTS can be stored directly.
   Some elements of OUTPUTS may be replaced with trees representing temporary
   values.  The caller should copy those temporary values to the originally
   specified lvalues.

   VOL nonzero means the insn is volatile; don't optimize it.  
     Vector of RTX's of evaluated output operands.  
     An ASM with no outputs needs to be treated as volatile, for now.  
     Collect constraints.  
     Sometimes we wish to automatically clobber registers across an asm.
     Case in point is when the i386 backend moved from cc0 to a hard reg --
     maintaining source-level compatibility means automatically clobbering
     the flags register.  
     Count the number of meaningful clobbered registers, ignoring what
     we would ignore later.  
         Mark clobbered registers.  
                 Clobbering the PIC register is an error.  
     First pass over inputs and outputs checks validity and sets
     mark_addressable if needed.  
         If there's an erroneous arg, emit no insn.  
         Try to parse the output constraint.  If that fails, there's
         no point in going further.  
         If there's an erroneous arg, emit no insn, because the ASM_INPUT
         would get VOIDmode and that could cause a crash in reload.  
     Second pass evaluates arguments.  
     Make sure stack is consistent for asm goto.  
         If an output operand is not a decl or indirect ref and our constraint
         allows a register, make a temporary to act as an intermediate.
         Make the asm insn write into that, then our caller will copy it to
         the real output operand.  Likewise for promoted variables.  
     Make vectors for the expression-rtx, constraint strings,
     and named operands.  
     Eval the inputs and put them into ARGVEC.
     Put their constraints into ASM_INPUTs and store in CONSTRAINTS.  
         EXPAND_INITIALIZER will not generate code for valid initializer
         constants, but will still generate code for other types of operand.
         This is the behavior we want for constant constraints.  
         Never pass a CONCAT to an ASM.  
                 We won't recognize either volatile memory or memory
                 with a queued address as available a memory_operand
                 at this point.  Ignore it: clearly this *is* a memory.  
     Protect all the operands from the queue now that they have all been
     evaluated.  
     For in-out operands, copy output rtx to input rtx.  
     Copy labels to the vector.  
         If asm goto has any labels in the fallthru basic block, use
         a label that we emit immediately after the asm goto.  Expansion
         may insert further instructions into the same basic block after
         asm goto and if we don't do this, insertion of instructions on
         the fallthru edge might misbehave.  See PR58670.  
     Now, for each output, construct an rtx
     (set OUTPUT (asm_operands INSN OUTPUTCONSTRAINT OUTPUTNUMBER
                               ARGVEC CONSTRAINTS OPNAMES))
     If there is more than one, put them inside a PARALLEL.  
         No output operands: put in a raw ASM_OPERANDS rtx.  
         For each output operand, store a SET.  
         If there are no outputs (but there are some clobbers)
         store the bare ASM_OPERANDS into the PARALLEL.  
         Store (clobber REG) for each clobbered register specified.  
                 Ignore unknown register, error already signaled.  
                 Use QImode since that's guaranteed to clobber just
               * one reg.  
                 Do sanity check for overlap between clobbers and
                 respectively input and outputs that hasn't been
                 handled.  Such overlap should have been detected and
                 reported above.  
                     We test the old body (obody) contents to avoid
                     tripping over the under-construction body.  
     For any outputs that needed reloading into registers, spill them
     back to where they belong.  

References targetm.

void expand_asm_stmt ( )
     Meh... convert the gimple asm operands into real tree lists.
     Eventually we should make all routines work on the vectors instead
     of relying on TREE_CHAIN.  
     o[I] is the place that output number I should be written.  
     Record the contents of OUTPUTS before it is modified.  
     Generate the ASM_OPERANDS insn; store into the TREE_VALUEs of
     OUTPUTS some trees for where the values were actually stored.  
     Copy all the intermediate outputs into the specified outputs.  
             Restore the original value so that it's correct the next
             time we expand this function.  

References expand_assignment(), and free_temp_slots().

void expand_case ( )
   Terminate a case (Pascal/Ada) or switch (C) statement
   in which ORIG_INDEX is the expression to be tested.
   If ORIG_TYPE is not NULL, it is the original ORIG_INDEX
   type as given in the source before any compiler conversions.
   Generate the code to test it and jump to the right place.  
     A list of case labels; it is first built as a list and it may then
     be rearranged into a nearly balanced binary tree.  
     A pool for case nodes.  
     An ERROR_MARK occurs for various reasons including invalid data type.
     ??? Can this still happen, with GIMPLE and all?  
     cleanup_tree_cfg removes all SWITCH_EXPR with their index
     expressions being INTEGER_CST.  
     Find the default case target label.  
     Get upper and lower bounds of case values.  
     Compute span of values.  
     Listify the labels queue and gather some numbers to decide
     how to expand this switch().  
         Count the elements.
         A range counts double, since it requires two compares.  
         If we have not seen this label yet, then increase the
         number of unique case node targets seen.  
         The bounds on the case range, LOW and HIGH, have to be converted
         to case's index type TYPE.  Note that the original type of the
         case index in the source code is usually "lost" during
         gimplification due to type promotion, but the case labels retain the
         original type.  Make sure to drop overflow flags.  
         The canonical from of a case label in GIMPLE is that a simple case
         has an empty CASE_HIGH.  For the casesi and tablejump expanders,
         the back ends want simple cases to have high == low.  
     cleanup_tree_cfg removes all SWITCH_EXPR with a single
     destination, such as one with a default case only.
     It also removes cases that are out of range for the switch
     type, so we should never get a zero here.  
     Decide how to expand this switch.
     The two options at this point are a dispatch table (casesi or
     tablejump) or a decision tree.  
void expand_computed_goto ( )
   Emit code to jump to the address
   specified by the pointer expression EXP.  

References do_pending_stack_adjust(), emit_label(), and label_rtx().

void expand_goto ( )
   Generate RTL code for a `goto' statement with target label LABEL.
   LABEL should be a LABEL_DECL tree node that was or will later be
   defined with `expand_label'.  
     Check for a nonlocal goto to a containing function.  Should have
     gotten translated to __builtin_nonlocal_goto.  
void expand_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.  
void expand_naked_return ( void  )
   Generate RTL to return directly from the current function.
   (That is, we bypass any return value.)  

References copy_blkmode_to_reg(), expand_null_return(), and expand_value_return().

void expand_null_return ( void  )
   Generate RTL to return from the current function, with no value.
   (That is, we do not do anything about returning any value.)  
     If this function was declared to return a value, but we
     didn't, clobber the return registers so that they are not
     propagated live to the rest of the function.  

Referenced by expand_naked_return().

static void expand_null_return_1 ( )
static
   Output a return with no value.  

References emit_stack_restore(), expand_normal(), fixup_args_size_notes(), get_last_insn(), and SAVE_BLOCK.

Referenced by resolve_operand_name_1().

void expand_return ( )
   Generate RTL to evaluate the expression RETVAL and return it
   from the current function.  
     If function wants no value, give it none.  
         Treat this like a return of no value from a function that
         returns a value.  
     If we are returning the RESULT_DECL, then the value has already
     been stored into it, so we don't have to do anything special.  
     If the result is an aggregate that is being returned in one (or more)
     registers, load the registers here.  
             Use the mode of the result value on the return register.  
         Calculate the return value into a temporary (usually a pseudo
         reg).  
         Return the calculated value.  
         No hard reg used; calculate value into hard return reg.  

References do_compare_rtx_and_jump().

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.  
     Expand as a decrement-chain if there are 5 or fewer dispatch
     labels.  This covers more than 98% of the cases in libjava,
     and seems to be a reasonable compromise between the "old way"
     of expanding as a decision tree or dispatch table vs. the "new
     way" with decrement chain or dispatch table.  
         Expand the dispatch as a decrement chain:

         "switch(index) {case 0: do_0; case 1: do_1; ...; case N: do_N;}"

         ==>

         if (index == 0) do_0; else index--;
         if (index == 0) do_1; else index--;
         ...
         if (index == 0) do_N; else index--;

         This is more efficient than a dispatch table on most machines.
         The last "index--" is redundant but the code is trivially dead
         and will be cleaned up by later passes.  
         Similar to expand_case, but much simpler.  
     Dispatching something not handled?  Trap!  
void expand_stack_restore ( )
   Emit code to restore the current value of stack.  
rtx expand_stack_save ( void  )
   Emit code to save the current value of stack.  
static bool expand_switch_as_decision_tree_p ( tree  range,
unsigned int  uniq,
unsigned int  count 
)
static
   Return true if a switch should be expanded as a decision tree.
   RANGE is the difference between highest and lowest case.
   UNIQ is number of unique case node targets, not counting the default case.
   COUNT is the number of comparisons needed, not counting the default case.  
     If neither casesi or tablejump is available, or flag_jump_tables
     over-ruled us, we really have no choice.  
     If the switch is relatively small such that the cost of one
     indirect jump on the target are higher than the cost of a
     decision tree, go with the decision tree.

     If range of values is much bigger than number of values,
     or if it is too large to represent in a HOST_WIDE_INT,
     make a sequence of conditional branches instead of a dispatch.

     The definition of "much bigger" depends on whether we are
     optimizing for size or for speed.  If the former, the maximum
     ratio range/count = 3, because this was found to be the optimal
     ratio for size on i686-pc-linux-gnu, see PR11823.  The ratio
     10 is much older, and was probably selected after an extensive
     benchmarking investigation on numerous platforms.  Or maybe it
     just made sense to someone at some point in the history of GCC,
     who knows...  

References edge_def::probability, and basic_block_def::succs.

static void expand_value_return ( rtx  )
static
static void expand_value_return ( )
static
   Generate RTL to return from the current function, with value VAL.  
     Copy the value to the return location unless it's already there.  

References assign_temp(), build_qualified_type(), current_function_decl, expand_expr(), EXPAND_NORMAL, expand_value_return(), force_not_mem(), and TYPE_QUAL_CONST.

rtx force_label_rtx ( )
   As above, but also put it on the forced-reference list of the
   function that contains it.  
static int get_outgoing_edge_probs ( )
static
   Return the sum of probabilities of outgoing edges of basic block BB.  
rtx label_rtx ( )
   Return the rtx-label that corresponds to a LABEL_DECL,
   creating it if necessary.  
basic_block label_to_block_fn ( struct function ,
tree   
)
static int n_occurrences ( int  ,
const char *   
)
static
static int n_occurrences ( )
static
   Return the number of times character C occurs in string S.  

References emit_insn().

static int node_has_high_bound ( case_node_ptr  ,
tree   
)
static
static int node_has_high_bound ( )
static
   Search the parent sections of the case node tree
   to see if a test for the upper bound of NODE would be redundant.
   INDEX_TYPE is the type of the index expression.

   The instructions to generate the case decision tree are
   output in the same order as nodes are processed so it is
   known that if a parent node checks the range of the current
   node plus one that the current node is bounded at its upper
   span.  Thus the test would be redundant.  
     If there is no upper bound, obviously no test is needed.  
     If the upper bound of this node is the highest value in the type
     of the index expression, we need not test against it.  
     If this node has a right branch, the value at the right must be greater
     than that at this node, so it cannot be bounded at the top and
     we need not bother testing any further.  
     If the addition above overflowed, we can't verify anything.
     Otherwise, look for a parent that tests our value + 1.  
static int node_has_low_bound ( case_node_ptr  ,
tree   
)
static
static int node_has_low_bound ( )
static
   Search the parent sections of the case node tree
   to see if a test for the lower bound of NODE would be redundant.
   INDEX_TYPE is the type of the index expression.

   The instructions to generate the case decision tree are
   output in the same order as nodes are processed so it is
   known that if a parent node checks the range of the current
   node minus one that the current node is bounded at its lower
   span.  Thus the test would be redundant.  
     If the lower bound of this node is the lowest value in the index type,
     we need not test it.  
     If this node has a left branch, the value at the left must be less
     than that at this node, so it cannot be bounded at the bottom and
     we need not bother testing any further.  
     If the subtraction above overflowed, we can't verify anything.
     Otherwise, look for a parent that tests our value - 1.  

References case_node::code_label, conditional_probability(), convert_modes(), emit_case_nodes(), emit_cmp_and_jump_insns(), expand_normal(), case_node::high, label_rtx(), case_node::left, case_node::prob, case_node::right, and case_node::subtree_prob.

static int node_is_bounded ( case_node_ptr  ,
tree   
)
static
static int node_is_bounded ( )
static
   Search the parent sections of the
   case node tree to see if both tests for the upper and lower
   bounds of NODE would be redundant.  
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 
)
   Similar, but for input constraints.  
     Assume the constraint doesn't allow the use of either
     a register or memory.  
     Make sure constraint has neither `=', `+', nor '&'.  
           Whether or not a numeric constraint allows a register is
           decided by the matching constraint, and so there is no need
           to do anything special with them.  We must handle them in
           the default case, so that we don't unnecessarily force
           operands to memory.  
             Try and find the real constraint for this dup.  Only do this
             if the matching constraint is the only alternative.  
                 ??? At the end of the loop, we will skip the first part of
                 the matched constraint.  This assumes not only that the
                 other constraint is an output constraint, but also that
                 the '=' or '+' come first.  
             Anticipate increment at end of loop.  
           Fall through.  
               Otherwise we can't assume anything about the nature of
               the constraint except that it isn't purely registers.
               Treat it like "g" and hope for the best.  

References error().

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.  
     Assume the constraint doesn't allow the use of either a register
     or memory.  
     Allow the `=' or `+' to not be at the beginning of the string,
     since it wasn't explicitly documented that way, and there is a
     large body of code that puts it last.  Swap the character to
     the front, so as not to uglify any place else.  
     If the string doesn't contain an `=', issue an error
     message.  
     If the constraint begins with `+', then the operand is both read
     from and written to.  
     Canonicalize the output constraint so that it begins with `='.  
         Make a copy of the constraint.  
         Swap the first character and the `=' or `+'.  
         Make sure the first character is an `='.  (Until we do this,
         it might be a `+'.)  
         Replace the constraint with the canonicalized string.  
     Loop through the constraint string.  
           ??? Before flow, auto inc/dec insns are not supposed to exist,
           excepting those that expand_call created.  So match memory
           and hope.  
               Otherwise we can't assume anything about the nature of
               the constraint except that it isn't purely registers.
               Treat it like "g" and hope for the best.  
static void reset_out_edges_aux ( )
inlinestatic
   Reset the aux field of all outgoing edges of basic block BB.  
tree resolve_asm_operand_names ( )
   A subroutine of expand_asm_operands.  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.  
     Substitute [<name>] in input constraint strings.  There should be no
     named operands in output constraints.  
     Now check for any needed substitutions in the template.  
         OK, we need to make a copy so we can perform the substitutions.
         Assume that we will not need extra space--we get to remove '['
         and ']', which means we cannot have a problem until we have more
         than 999 operands.  

References error().

Referenced by tree_conflicts_with_clobbers_p().

static char* resolve_operand_name_1 ( char *  ,
tree  ,
tree  ,
tree   
)
static
static char* resolve_operand_name_1 ( )
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.  
     Collect the operand name.  
     Resolve the name to a number.  
     Replace the name with the number.  Unfortunately, not all libraries
     get the return value of sprintf correct, so search for the end of the
     generated string by hand.  
     Verify the no extra buffer space assumption.  
     Shift the rest of the buffer down to fill the gap.  

References convert_modes(), current_function_decl, emit_group_load(), emit_move_insn(), expand_null_return_1(), int_size_in_bytes(), and promote_function_mode().

static bool tree_conflicts_with_clobbers_p ( tree  ,
HARD_REG_SET  
)
static
static bool tree_conflicts_with_clobbers_p ( )
static
   Check for overlap between registers marked in CLOBBERED_REGS and
   anything inappropriate in T.  Emit error and return the register
   variable definition for error, NULL_TREE for ok.  
     Conflicts between asm-declared register variables and the clobber
     list are not allowed.  
         Reset registerness to stop multiple errors emitted for a single
         variable.  

References check_operand_nalternatives(), generating_concat_p, list_length(), and resolve_asm_operand_names().

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

Referenced by decl_overlaps_hard_reg_set_p().