GCC Middle and Back End API 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"
Data Structures | |
class | simple_case_node |
Functions | |
static bool | check_unique_operand_names (tree, tree, tree) |
static char * | resolve_operand_name_1 (char *, tree, tree, tree) |
rtx_insn * | label_rtx (tree label) |
rtx_insn * | force_label_rtx (tree label) |
rtx_code_label * | jump_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) |
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, i, NULL_TREE, simple_cst_equal(), TREE_CHAIN, TREE_PURPOSE, and TREE_STRING_POINTER.
Referenced by resolve_asm_operand_names().
|
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.
Referenced by emit_case_dispatch_table().
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, NULL_TREE, overlaps_hard_reg_set_p(), REG_P, REGNO, TREE_CODE, TYPE_P, and VAR_P.
Referenced by tree_overlaps_hard_reg_set().
|
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(), NULL, and NULL_RTX.
Referenced by expand_sjlj_dispatch_table().
|
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(), 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(), basic_block_def::succs, targetm, tree_to_shwi(), tree_to_uhwi(), try_casesi(), and try_tablejump().
Referenced by expand_case(), and expand_sjlj_dispatch_table().
void emit_jump | ( | rtx | label | ) |
Add an unconditional jump to LABEL as the next sequential instruction.
References do_pending_stack_adjust(), emit_barrier(), emit_jump_insn(), and targetm.
Referenced by allocate_dynamic_stack_space(), anti_adjust_stack_and_probe(), asan_emit_stack_protection(), compare_by_pieces(), construct_init_block(), do_compare_rtx_and_jump(), do_jump(), do_jump_by_parts_equality_rtx(), do_jump_by_parts_greater_rtx(), do_jump_by_parts_zero_rtx(), emit_block_cmp_via_loop(), emit_block_move_via_loop(), emit_block_move_via_oriented_loop(), emit_stack_clash_protection_probe_loop_end(), expand_addsub_overflow(), expand_builtin_eh_return(), expand_eh_return(), expand_gimple_basic_block(), expand_gimple_cond(), expand_goto(), expand_mul_overflow(), expand_naked_return(), expand_neg_overflow(), expand_null_return_1(), probe_stack_range(), and store_constructor().
void expand_case | ( | gswitch * | stmt | ) |
Terminate a case 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.
References bb_seq(), BITS_PER_WORD, CASE_HIGH, CASE_LABEL, CASE_LOW, cfun, count, do_pending_stack_adjust(), EDGE_COUNT, emit_case_dispatch_table(), error_mark_node, find_edge(), fold_build2, fold_convert, free_temp_slots(), gcc_assert, get_last_insn(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_bb(), gimple_seq_unreachable_p(), gimple_switch_default_label(), gimple_switch_index(), gimple_switch_label(), gimple_switch_num_labels(), i, int_fits_type_p(), INTEGRAL_TYPE_P, is_gimple_assign(), jump_target_rtx(), label_to_block(), NEXT_INSN(), NULL, NULL_TREE, remove_edge(), reorder_insns(), SSA_NAME_DEF_STMT, wi::to_wide(), TREE_CODE, tree_int_cst_lt(), TREE_OVERFLOW, TREE_TYPE, TYPE_PRECISION, and wide_int_to_tree().
Referenced by expand_gimple_stmt_1().
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(), IDENTIFIER_POINTER, jump_target_rtx(), LABEL_NAME, maybe_set_first_label_num(), nonlocal_goto_handler_labels, NULL, and vec_safe_push().
Referenced by expand_gimple_stmt_1().
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 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(), 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().
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().
|
static |
Return the sum of probabilities of outgoing edges of basic block BB.
References FOR_EACH_EDGE, profile_probability::never(), and basic_block_def::succs.
Referenced by emit_case_dispatch_table().
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 as_a(), 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().
Return the rtx-label that corresponds to a LABEL_DECL, creating it if necessary.
References as_a(), DECL_NONLOCAL, DECL_RTL, DECL_RTL_SET_P, FORCED_LABEL, gcc_assert, gen_label_rtx(), LABEL_PRESERVE_P, r, SET_DECL_RTL, and TREE_CODE.
Referenced by dump_eh_tree(), dw2_build_landing_pads(), emit_case_dispatch_table(), expand_asm_stmt(), expand_builtin(), expand_expr_real_1(), finish_eh_generation(), force_label_rtx(), jump_target_rtx(), mark_transaction_restart_calls(), rtl_make_eh_edge(), and sjlj_emit_dispatch_table().
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.
References constraints, end(), error(), and warning().
Referenced by assemble_asm(), 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().
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_string(), and warning().
Referenced by assemble_asm(), 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 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(), NULL, resolve_operand_name_1(), TREE_CHAIN, TREE_PURPOSE, TREE_STRING_POINTER, and TREE_VALUE.
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, identifier_to_locale(), NULL, TREE_CHAIN, TREE_PURPOSE, TREE_STRING_POINTER, and TREE_VALUE.
Referenced by resolve_asm_operand_names().
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().