/* Maximum size (in bytes) of an artificially generated label. */
#define MAX_ARTIFICIAL_LABEL_BYTES 30
+
+/* Short-hand for commonly used register numbers. */
+#define DW_STACK_POINTER_REGNUM dwarf_frame_regnum (STACK_POINTER_REGNUM)
+#define DW_FRAME_POINTER_REGNUM dwarf_frame_regnum (HARD_FRAME_POINTER_REGNUM)
\f
/* A vector of call frame insns for the CIE. */
cfi_vec cie_cfi_vec;
rtx
expand_builtin_dwarf_sp_column (void)
{
- unsigned int dwarf_regnum = DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM);
+ unsigned int dwarf_regnum = DW_STACK_POINTER_REGNUM;
return GEN_INT (DWARF2_FRAME_REG_OUT (dwarf_regnum, 1));
}
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
{
- int rnum = DWARF2_FRAME_REG_OUT (DWARF_FRAME_REGNUM (i), 1);
+ unsigned int rnum = DWARF2_FRAME_REG_OUT (dwarf_frame_regnum (i), 1);
if (rnum < DWARF_FRAME_REGISTERS)
{
if (HARD_REGNO_CALL_PART_CLOBBERED (i, save_mode))
save_mode = choose_hard_reg_mode (i, 1, true);
- if (DWARF_FRAME_REGNUM (i) == DWARF_FRAME_RETURN_COLUMN)
+ if (dwarf_frame_regnum (i) == DWARF_FRAME_RETURN_COLUMN)
{
if (save_mode == VOIDmode)
continue;
if (cfa_store.reg == loc.reg && loc.indirect == 0)
cfa_store.offset = loc.offset;
- loc.reg = DWARF_FRAME_REGNUM (loc.reg);
-
/* If nothing changed, no need to issue any call frame instructions. */
if (cfa_equal_p (&loc, &old_cfa))
return;
static void
dwarf2out_stack_adjust (HOST_WIDE_INT offset)
{
- if (cfa.reg == STACK_POINTER_REGNUM)
+ if (cfa.reg == DW_STACK_POINTER_REGNUM)
cfa.offset += offset;
- if (cfa_store.reg == STACK_POINTER_REGNUM)
+ if (cfa_store.reg == DW_STACK_POINTER_REGNUM)
cfa_store.offset += offset;
if (ACCUMULATE_OUTGOING_ARGS)
/* If only calls can throw, and we have a frame pointer,
save up adjustments until we see the CALL_INSN. */
- if (!flag_asynchronous_unwind_tables && cfa.reg != STACK_POINTER_REGNUM)
+ if (!flag_asynchronous_unwind_tables && cfa.reg != DW_STACK_POINTER_REGNUM)
{
if (CALL_P (insn) && !after_p)
{
static GTY(()) reg_saved_in_data *cie_return_save;
+/* Short-hand inline for the very common D_F_R (REGNO (x)) operation. */
+/* ??? This ought to go into dwarf2out.h alongside dwarf_frame_regnum,
+ except that dwarf2out.h is used in places where rtl is prohibited. */
+
+static inline unsigned
+dwf_regno (const_rtx reg)
+{
+ return dwarf_frame_regnum (REGNO (reg));
+}
+
/* Compare X and Y for equivalence. The inputs may be REGs or PC_RTX. */
static bool
if (q->reg == pc_rtx)
reg = DWARF_FRAME_RETURN_COLUMN;
else
- reg = DWARF_FRAME_REGNUM (REGNO (q->reg));
+ reg = dwf_regno (q->reg);
if (q->saved_reg)
- sreg = DWARF_FRAME_REGNUM (REGNO (q->saved_reg));
+ sreg = dwf_regno (q->saved_reg);
else
sreg = INVALID_REGNUM;
reg_save (reg, sreg, q->cfa_offset);
switch (GET_CODE (pat))
{
case PLUS:
- cfa.reg = REGNO (XEXP (pat, 0));
+ cfa.reg = dwf_regno (XEXP (pat, 0));
cfa.offset = INTVAL (XEXP (pat, 1));
break;
case REG:
- cfa.reg = REGNO (pat);
+ cfa.reg = dwf_regno (pat);
break;
case MEM:
cfa.base_offset = INTVAL (XEXP (pat, 1));
pat = XEXP (pat, 0);
}
- cfa.reg = REGNO (pat);
+ cfa.reg = dwf_regno (pat);
break;
default:
switch (GET_CODE (src))
{
case PLUS:
- gcc_assert (REGNO (XEXP (src, 0)) == cfa.reg);
+ gcc_assert (dwf_regno (XEXP (src, 0)) == cfa.reg);
cfa.offset -= INTVAL (XEXP (src, 1));
break;
gcc_unreachable ();
}
- cfa.reg = REGNO (dest);
+ cfa.reg = dwf_regno (dest);
gcc_assert (cfa.indirect == 0);
def_cfa_1 (&cfa);
switch (GET_CODE (addr))
{
case REG:
- gcc_assert (REGNO (addr) == cfa.reg);
+ gcc_assert (dwf_regno (addr) == cfa.reg);
offset = -cfa.offset;
break;
case PLUS:
- gcc_assert (REGNO (XEXP (addr, 0)) == cfa.reg);
+ gcc_assert (dwf_regno (XEXP (addr, 0)) == cfa.reg);
offset = INTVAL (XEXP (addr, 1)) - cfa.offset;
break;
default:
else
{
span = targetm.dwarf_register_span (src);
- sregno = DWARF_FRAME_REGNUM (REGNO (src));
+ sregno = dwf_regno (src);
}
/* ??? We'd like to use queue_reg_save, but we need to come up with
{
rtx elem = XVECEXP (span, 0, par_index);
- sregno = DWARF_FRAME_REGNUM (REGNO (src));
+ sregno = dwf_regno (src);
reg_save (sregno, INVALID_REGNUM, span_offset);
span_offset += GET_MODE_SIZE (GET_MODE (elem));
}
if (src == pc_rtx)
sregno = DWARF_FRAME_RETURN_COLUMN;
else
- sregno = DWARF_FRAME_REGNUM (REGNO (src));
+ sregno = dwf_regno (src);
- dregno = DWARF_FRAME_REGNUM (REGNO (dest));
+ dregno = dwf_regno (dest);
/* ??? We'd like to use queue_reg_save, but we need to come up with
a different flushing heuristic for epilogues. */
gcc_assert (!span);
cfi->dw_cfi_opc = DW_CFA_expression;
- cfi->dw_cfi_oprnd1.dw_cfi_reg_num = DWARF_FRAME_REGNUM (REGNO (src));
+ cfi->dw_cfi_oprnd1.dw_cfi_reg_num = dwf_regno (src);
cfi->dw_cfi_oprnd2.dw_cfi_loc
= mem_loc_descriptor (XEXP (dest, 0), get_address_mode (dest),
GET_MODE (dest), VAR_INIT_STATUS_INITIALIZED);
dwarf2out_frame_debug_cfa_restore (rtx reg)
{
dw_cfi_ref cfi = new_cfi ();
- unsigned int regno = DWARF_FRAME_REGNUM (REGNO (reg));
+ unsigned int regno = dwf_regno (reg);
cfi->dw_cfi_opc = (regno & ~0x3f ? DW_CFA_restore_extended : DW_CFA_restore);
cfi->dw_cfi_oprnd1.dw_cfi_reg_num = regno;
{
/* Setting FP from SP. */
case REG:
- if (cfa.reg == (unsigned) REGNO (src))
+ if (cfa.reg == dwf_regno (src))
{
/* Rule 1 */
/* Update the CFA rule wrt SP or FP. Make sure src is
ARM copies SP to a temporary register, and from there to
FP. So we just rely on the backends to only set
RTX_FRAME_RELATED_P on appropriate insns. */
- cfa.reg = REGNO (dest);
+ cfa.reg = dwf_regno (dest);
cfa_temp.reg = cfa.reg;
cfa_temp.offset = cfa.offset;
}
/* Saving a register in a register. */
gcc_assert (!fixed_regs [REGNO (dest)]
/* For the SPARC and its register window. */
- || (DWARF_FRAME_REGNUM (REGNO (src))
- == DWARF_FRAME_RETURN_COLUMN));
+ || (dwf_regno (src) == DWARF_FRAME_RETURN_COLUMN));
/* After stack is aligned, we can only save SP in FP
if drap register is used. In this case, we have
&& REGNO (src) == STACK_POINTER_REGNUM)
gcc_assert (REGNO (dest) == HARD_FRAME_POINTER_REGNUM
&& fde->drap_reg != INVALID_REGNUM
- && cfa.reg != REGNO (src));
+ && cfa.reg != dwf_regno (src));
else
queue_reg_save (src, dest, 0);
}
offset = INTVAL (XEXP (src, 1));
break;
case REG:
- gcc_assert ((unsigned) REGNO (XEXP (src, 1))
- == cfa_temp.reg);
+ gcc_assert (dwf_regno (XEXP (src, 1)) == cfa_temp.reg);
offset = cfa_temp.offset;
break;
default:
if (XEXP (src, 0) == hard_frame_pointer_rtx)
{
/* Restoring SP from FP in the epilogue. */
- gcc_assert (cfa.reg == (unsigned) HARD_FRAME_POINTER_REGNUM);
- cfa.reg = STACK_POINTER_REGNUM;
+ gcc_assert (cfa.reg == DW_FRAME_POINTER_REGNUM);
+ cfa.reg = DW_STACK_POINTER_REGNUM;
}
else if (GET_CODE (src) == LO_SUM)
/* Assume we've set the source reg of the LO_SUM from sp. */
if (GET_CODE (src) != MINUS)
offset = -offset;
- if (cfa.reg == STACK_POINTER_REGNUM)
+ if (cfa.reg == DW_STACK_POINTER_REGNUM)
cfa.offset += offset;
- if (cfa_store.reg == STACK_POINTER_REGNUM)
+ if (cfa_store.reg == DW_STACK_POINTER_REGNUM)
cfa_store.offset += offset;
}
else if (dest == hard_frame_pointer_rtx)
gcc_assert (frame_pointer_needed);
gcc_assert (REG_P (XEXP (src, 0))
- && (unsigned) REGNO (XEXP (src, 0)) == cfa.reg
+ && dwf_regno (XEXP (src, 0)) == cfa.reg
&& CONST_INT_P (XEXP (src, 1)));
offset = INTVAL (XEXP (src, 1));
if (GET_CODE (src) != MINUS)
offset = -offset;
cfa.offset += offset;
- cfa.reg = HARD_FRAME_POINTER_REGNUM;
+ cfa.reg = DW_FRAME_POINTER_REGNUM;
}
else
{
/* Rule 4 */
if (REG_P (XEXP (src, 0))
- && REGNO (XEXP (src, 0)) == cfa.reg
+ && dwf_regno (XEXP (src, 0)) == cfa.reg
&& CONST_INT_P (XEXP (src, 1)))
{
/* Setting a temporary CFA register that will be copied
into the FP later on. */
offset = - INTVAL (XEXP (src, 1));
cfa.offset += offset;
- cfa.reg = REGNO (dest);
+ cfa.reg = dwf_regno (dest);
/* Or used to save regs to the stack. */
cfa_temp.reg = cfa.reg;
cfa_temp.offset = cfa.offset;
/* Rule 5 */
else if (REG_P (XEXP (src, 0))
- && REGNO (XEXP (src, 0)) == cfa_temp.reg
+ && dwf_regno (XEXP (src, 0)) == cfa_temp.reg
&& XEXP (src, 1) == stack_pointer_rtx)
{
/* Setting a scratch register that we will use instead
of SP for saving registers to the stack. */
- gcc_assert (cfa.reg == STACK_POINTER_REGNUM);
- cfa_store.reg = REGNO (dest);
+ gcc_assert (cfa.reg == DW_STACK_POINTER_REGNUM);
+ cfa_store.reg = dwf_regno (dest);
cfa_store.offset = cfa.offset - cfa_temp.offset;
}
else if (GET_CODE (src) == LO_SUM
&& CONST_INT_P (XEXP (src, 1)))
{
- cfa_temp.reg = REGNO (dest);
+ cfa_temp.reg = dwf_regno (dest);
cfa_temp.offset = INTVAL (XEXP (src, 1));
}
else
/* Rule 6 */
case CONST_INT:
- cfa_temp.reg = REGNO (dest);
+ cfa_temp.reg = dwf_regno (dest);
cfa_temp.offset = INTVAL (src);
break;
/* Rule 7 */
case IOR:
gcc_assert (REG_P (XEXP (src, 0))
- && (unsigned) REGNO (XEXP (src, 0)) == cfa_temp.reg
+ && dwf_regno (XEXP (src, 0)) == cfa_temp.reg
&& CONST_INT_P (XEXP (src, 1)));
- if ((unsigned) REGNO (dest) != cfa_temp.reg)
- cfa_temp.reg = REGNO (dest);
+ cfa_temp.reg = dwf_regno (dest);
cfa_temp.offset |= INTVAL (XEXP (src, 1));
break;
Thus we must flush whatever we have queued first. */
dwarf2out_flush_queued_reg_saves ();
- gcc_assert (cfa_store.reg == REGNO (XEXP (src, 0)));
+ gcc_assert (cfa_store.reg == dwf_regno (XEXP (src, 0)));
fde->stack_realign = 1;
fde->stack_realignment = INTVAL (XEXP (src, 1));
cfa_store.offset = 0;
- if (cfa.reg != STACK_POINTER_REGNUM
- && cfa.reg != HARD_FRAME_POINTER_REGNUM)
+ if (cfa.reg != DW_STACK_POINTER_REGNUM
+ && cfa.reg != DW_FRAME_POINTER_REGNUM)
fde->drap_reg = cfa.reg;
}
return;
offset = -INTVAL (XEXP (XEXP (XEXP (dest, 0), 1), 1));
gcc_assert (REGNO (XEXP (XEXP (dest, 0), 0)) == STACK_POINTER_REGNUM
- && cfa_store.reg == STACK_POINTER_REGNUM);
+ && cfa_store.reg == DW_STACK_POINTER_REGNUM);
cfa_store.offset += offset;
- if (cfa.reg == STACK_POINTER_REGNUM)
+ if (cfa.reg == DW_STACK_POINTER_REGNUM)
cfa.offset = cfa_store.offset;
if (GET_CODE (XEXP (dest, 0)) == POST_MODIFY)
gcc_assert ((REGNO (XEXP (XEXP (dest, 0), 0))
== STACK_POINTER_REGNUM)
- && cfa_store.reg == STACK_POINTER_REGNUM);
+ && cfa_store.reg == DW_STACK_POINTER_REGNUM);
cfa_store.offset += offset;
&& fde->stack_realign
&& src == hard_frame_pointer_rtx)
{
- gcc_assert (cfa.reg != HARD_FRAME_POINTER_REGNUM);
+ gcc_assert (cfa.reg != DW_FRAME_POINTER_REGNUM);
cfa_store.offset = 0;
}
- if (cfa.reg == STACK_POINTER_REGNUM)
+ if (cfa.reg == DW_STACK_POINTER_REGNUM)
cfa.offset = cfa_store.offset;
if (GET_CODE (XEXP (dest, 0)) == POST_DEC)
case MINUS:
case LO_SUM:
{
- int regno;
+ unsigned int regno;
gcc_assert (CONST_INT_P (XEXP (XEXP (dest, 0), 1))
&& REG_P (XEXP (XEXP (dest, 0), 0)));
if (GET_CODE (XEXP (dest, 0)) == MINUS)
offset = -offset;
- regno = REGNO (XEXP (XEXP (dest, 0), 0));
+ regno = dwf_regno (XEXP (XEXP (dest, 0), 0));
- if (cfa.reg == (unsigned) regno)
+ if (cfa.reg == regno)
offset -= cfa.offset;
- else if (cfa_store.reg == (unsigned) regno)
+ else if (cfa_store.reg == regno)
offset -= cfa_store.offset;
else
{
- gcc_assert (cfa_temp.reg == (unsigned) regno);
+ gcc_assert (cfa_temp.reg == regno);
offset -= cfa_temp.offset;
}
}
/* Without an offset. */
case REG:
{
- int regno = REGNO (XEXP (dest, 0));
+ unsigned int regno = dwf_regno (XEXP (dest, 0));
- if (cfa.reg == (unsigned) regno)
+ if (cfa.reg == regno)
offset = -cfa.offset;
- else if (cfa_store.reg == (unsigned) regno)
+ else if (cfa_store.reg == regno)
offset = -cfa_store.offset;
else
{
- gcc_assert (cfa_temp.reg == (unsigned) regno);
+ gcc_assert (cfa_temp.reg == regno);
offset = -cfa_temp.offset;
}
}
/* Rule 14 */
case POST_INC:
- gcc_assert (cfa_temp.reg
- == (unsigned) REGNO (XEXP (XEXP (dest, 0), 0)));
+ gcc_assert (cfa_temp.reg == dwf_regno (XEXP (XEXP (dest, 0), 0)));
offset = -cfa_temp.offset;
cfa_temp.offset -= GET_MODE_SIZE (GET_MODE (dest));
break;
if (REG_P (src)
&& REGNO (src) != STACK_POINTER_REGNUM
&& REGNO (src) != HARD_FRAME_POINTER_REGNUM
- && (unsigned) REGNO (src) == cfa.reg)
+ && dwf_regno (src) == cfa.reg)
{
/* We're storing the current CFA reg into the stack. */
if (fde
&& fde->stack_realign
&& cfa.indirect == 0
- && cfa.reg != HARD_FRAME_POINTER_REGNUM)
+ && cfa.reg != DW_FRAME_POINTER_REGNUM)
{
dw_cfa_location cfa_exp;
gcc_assert (fde->drap_reg == cfa.reg);
cfa_exp.indirect = 1;
- cfa_exp.reg = HARD_FRAME_POINTER_REGNUM;
+ cfa_exp.reg = DW_FRAME_POINTER_REGNUM;
cfa_exp.base_offset = offset;
cfa_exp.offset = 0;
x = XEXP (x, 0);
gcc_assert (REG_P (x));
- cfa.reg = REGNO (x);
+ cfa.reg = dwf_regno (x);
cfa.base_offset = offset;
cfa.indirect = 1;
def_cfa_1 (&cfa);
{
gcc_assert (fde->vdrap_reg == INVALID_REGNUM);
if (REG_P (n))
- fde->vdrap_reg = REGNO (n);
+ fde->vdrap_reg = dwf_regno (n);
}
}
handled_one = true;
{
case REG:
/* RA is in a register. */
- reg = DWARF_FRAME_REGNUM (REGNO (rtl));
+ reg = dwf_regno (rtl);
break;
case MEM:
/* On entry, the Canonical Frame Address is at SP. */
memset(&loc, 0, sizeof (loc));
- loc.reg = STACK_POINTER_REGNUM;
+ loc.reg = DW_STACK_POINTER_REGNUM;
loc.offset = INCOMING_FRAME_SP_OFFSET;
def_cfa_1 (&loc);
gcc_checking_assert (regs_saved_in_regs == NULL);
memset (&cfa, 0, sizeof(cfa));
- cfa.reg = STACK_POINTER_REGNUM;
+ cfa.reg = DW_STACK_POINTER_REGNUM;
cfa.offset = INCOMING_FRAME_SP_OFFSET;
old_cfa = cfa;