GCC Middle and Back End API Reference
combine-stack-adj.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "df.h"
#include "insn-config.h"
#include "memmodel.h"
#include "emit-rtl.h"
#include "recog.h"
#include "cfgrtl.h"
#include "tree-pass.h"
#include "rtl-iter.h"
Include dependency graph for combine-stack-adj.cc:

Data Structures

struct  csa_reflist
 

Functions

static bool stack_memref_p (rtx)
 
static rtx single_set_for_csa (rtx_insn *)
 
static void free_csa_reflist (struct csa_reflist *)
 
static struct csa_reflistrecord_one_stack_ref (rtx_insn *, rtx *, struct csa_reflist *)
 
static bool try_apply_stack_adjustment (rtx_insn *, struct csa_reflist *, HOST_WIDE_INT, HOST_WIDE_INT, bitmap, rtx_insn *)
 
static void combine_stack_adjustments_for_block (basic_block, bitmap)
 
static void combine_stack_adjustments (void)
 
static bool no_unhandled_cfa (rtx_insn *insn)
 
static bool record_stack_refs (rtx_insn *insn, struct csa_reflist **reflist)
 
static void maybe_move_args_size_note (rtx_insn *last, rtx_insn *insn, bool after)
 
static void maybe_merge_cfa_adjust (rtx_insn *dst, rtx_insn *src, bool after)
 
static rtx_insnprev_active_insn_bb (basic_block bb, rtx_insn *insn)
 
static rtx_insnnext_active_insn_bb (basic_block bb, rtx_insn *insn)
 
static void force_move_args_size_note (basic_block bb, rtx_insn *prev, rtx_insn *insn)
 
static void rest_of_handle_stack_adjustments (void)
 
rtl_opt_passmake_pass_stack_adjustments (gcc::context *ctxt)
 

Function Documentation

◆ combine_stack_adjustments()

static void combine_stack_adjustments ( void )
static
Main entry point for stack adjustment combination.   

References BITMAP_ALLOC, BITMAP_FREE, cfun, combine_stack_adjustments_for_block(), FOR_EACH_BB_FN, and reg_obstack.

Referenced by rest_of_handle_stack_adjustments().

◆ combine_stack_adjustments_for_block()

◆ force_move_args_size_note()

static void force_move_args_size_note ( basic_block bb,
rtx_insn * prev,
rtx_insn * insn )
static
If INSN has a REG_ARGS_SIZE note, if possible move it to PREV.  Otherwise
search for a nearby candidate within BB where we can stick the note.   

References add_reg_note(), CALL_P, const0_rtx, emit_insn_before(), find_reg_note(), ggc_alloc(), csa_reflist::insn, insn_nothrow_p(), maybe_move_args_size_note(), next_active_insn_bb(), NULL, NULL_RTX, prev_active_insn_bb(), and XEXP.

Referenced by combine_stack_adjustments_for_block().

◆ free_csa_reflist()

static void free_csa_reflist ( struct csa_reflist * reflist)
static
Free the list of csa_reflist nodes.   

References free(), ggc_alloc(), and csa_reflist::next.

Referenced by combine_stack_adjustments_for_block().

◆ make_pass_stack_adjustments()

rtl_opt_pass * make_pass_stack_adjustments ( gcc::context * ctxt)

References ggc_alloc().

◆ maybe_merge_cfa_adjust()

static void maybe_merge_cfa_adjust ( rtx_insn * dst,
rtx_insn * src,
bool after )
static
Merge any REG_CFA_ADJUST_CFA note from SRC into DST.
AFTER is true iff DST follows SRC in the instruction stream.   

References add_reg_note(), find_reg_note(), gcc_assert, GET_CODE, ggc_alloc(), NULL, NULL_RTX, RTX_FRAME_RELATED_P, SET, SET_DEST, SET_SRC, simplify_replace_rtx(), and XEXP.

Referenced by combine_stack_adjustments_for_block().

◆ maybe_move_args_size_note()

static void maybe_move_args_size_note ( rtx_insn * last,
rtx_insn * insn,
bool after )
static
If INSN has a REG_ARGS_SIZE note, move it to LAST.
AFTER is true iff LAST follows INSN in the instruction stream.   

References add_reg_note(), find_reg_note(), ggc_alloc(), csa_reflist::insn, last, NULL, NULL_RTX, and XEXP.

Referenced by combine_stack_adjustments_for_block(), and force_move_args_size_note().

◆ next_active_insn_bb()

static rtx_insn * next_active_insn_bb ( basic_block bb,
rtx_insn * insn )
static

◆ no_unhandled_cfa()

static bool no_unhandled_cfa ( rtx_insn * insn)
static
We only know how to adjust the CFA; no other frame-related changes
may appear in any insn to be deleted.   

References ggc_alloc(), csa_reflist::insn, REG_NOTE_KIND, REG_NOTES, RTX_FRAME_RELATED_P, and XEXP.

Referenced by combine_stack_adjustments_for_block().

◆ prev_active_insn_bb()

static rtx_insn * prev_active_insn_bb ( basic_block bb,
rtx_insn * insn )
static
Return the next (or previous) active insn within BB.   

References active_insn_p(), BB_HEAD, csa_reflist::insn, NULL, and PREV_INSN().

Referenced by force_move_args_size_note().

◆ record_one_stack_ref()

static struct csa_reflist * record_one_stack_ref ( rtx_insn * insn,
rtx * ref,
struct csa_reflist * next_reflist )
static
Create a new csa_reflist node from the given stack reference.
It is already known that the reference is either a MEM satisfying the
predicate stack_memref_p or a REG representing the stack pointer.   

References ggc_alloc(), csa_reflist::insn, INTVAL, csa_reflist::ref, REG_P, stack_pointer_rtx, and XEXP.

Referenced by record_stack_refs().

◆ record_stack_refs()

static bool record_stack_refs ( rtx_insn * insn,
struct csa_reflist ** reflist )
static
For non-debug insns, record all stack memory references in INSN
and return true if there were no other (unrecorded) references to the
stack pointer.  For debug insns, record all stack references regardless
of context and unconditionally return true.   

References DEBUG_INSN_P, FOR_EACH_SUBRTX_PTR, GET_CODE, ggc_alloc(), csa_reflist::insn, PATTERN(), record_one_stack_ref(), reg_mentioned_p(), REGNO, stack_memref_p(), and stack_pointer_rtx.

Referenced by combine_stack_adjustments_for_block().

◆ rest_of_handle_stack_adjustments()

static void rest_of_handle_stack_adjustments ( void )
static

◆ single_set_for_csa()

static rtx single_set_for_csa ( rtx_insn * insn)
static
Recognize either normal single_set or the hack in i386.md for
tying fp and sp adjustments.   

References GET_CODE, ggc_alloc(), i, csa_reflist::insn, NONJUMP_INSN_P, NULL_RTX, PATTERN(), SET, SET_DEST, SET_SRC, single_set(), XVECEXP, and XVECLEN.

Referenced by combine_stack_adjustments_for_block(), and try_apply_stack_adjustment().

◆ stack_memref_p()

static bool stack_memref_p ( rtx x)
static
Recognize a MEM of the form (sp) or (plus sp const).   

References CONST_INT_P, GET_CODE, ggc_alloc(), MEM_P, stack_pointer_rtx, and XEXP.

Referenced by record_stack_refs().

◆ try_apply_stack_adjustment()

static bool try_apply_stack_adjustment ( rtx_insn * insn,
struct csa_reflist * reflist,
HOST_WIDE_INT new_adjust,
HOST_WIDE_INT delta,
bitmap live,
rtx_insn * other_insn )
static