This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [h8300] Add dwarf2 debugging support
Ok, then, here's the patch as-is without that case being handled. I'm
open to alternate wordings on that comment, otherwise, OK to commit?
Index: h8300.c
===================================================================
--- h8300.c (revision 152793)
+++ h8300.c (working copy)
@@ -504,12 +504,38 @@ byte_reg (rtx x, int b)
/* Save call clobbered registers in non-leaf interrupt \
handlers. */ \
|| (h8300_current_function_interrupt_function_p () \
&& call_used_regs[regno] \
&& !current_function_is_leaf)))
+/* We use this to wrap all emitted insns in the prologue. */
+static rtx
+F (rtx x)
+{
+ RTX_FRAME_RELATED_P (x) = 1;
+ return x;
+}
+
+/* Mark all the subexpressions of the PARALLEL rtx PAR as
+ frame-related. Return PAR.
+
+ dwarf2out.c:dwarf2out_frame_debug_expr ignores sub-expressions of a
+ PARALLEL rtx other than the first if they do not have the
+ FRAME_RELATED flag set on them. */
+static rtx
+Fpa (rtx par)
+{
+ int len = XVECLEN (par, 0);
+ int i;
+
+ for (i = 0; i < len; i++)
+ F (XVECEXP (par, 0, i));
+
+ return par;
+}
+
/* Output assembly language to FILE for the operation OP with operand size
SIZE to adjust the stack pointer. */
static void
h8300_emit_stack_adjustment (int sign, HOST_WIDE_INT size)
{
@@ -523,28 +549,33 @@ h8300_emit_stack_adjustment (int sign, H
if (TARGET_H8300
&& size > 4
&& !h8300_current_function_interrupt_function_p ()
&& !(cfun->static_chain_decl != NULL && sign < 0))
{
rtx r3 = gen_rtx_REG (Pmode, 3);
- emit_insn (gen_movhi (r3, GEN_INT (sign * size)));
- emit_insn (gen_addhi3 (stack_pointer_rtx,
- stack_pointer_rtx, r3));
+ F (emit_insn (gen_movhi (r3, GEN_INT (sign * size))));
+ F (emit_insn (gen_addhi3 (stack_pointer_rtx,
+ stack_pointer_rtx, r3)));
}
else
{
/* The stack adjustment made here is further optimized by the
splitter. In case of H8/300, the splitter always splits the
- addition emitted here to make the adjustment
- interrupt-safe. */
+ addition emitted here to make the adjustment interrupt-safe.
+ FIXME: We don't always tag those, because we don't know what
+ the splitter will do. */
if (Pmode == HImode)
- emit_insn (gen_addhi3 (stack_pointer_rtx,
- stack_pointer_rtx, GEN_INT (sign * size)));
+ {
+ rtx x = emit_insn (gen_addhi3 (stack_pointer_rtx,
+ stack_pointer_rtx, GEN_INT (sign * size)));
+ if (size < 4)
+ F (x);
+ }
else
- emit_insn (gen_addsi3 (stack_pointer_rtx,
- stack_pointer_rtx, GEN_INT (sign * size)));
+ F (emit_insn (gen_addsi3 (stack_pointer_rtx,
+ stack_pointer_rtx, GEN_INT (sign * size))));
}
}
/* Round up frame size SIZE. */
static HOST_WIDE_INT
@@ -588,13 +619,13 @@ push (int rn)
if (TARGET_H8300)
x = gen_push_h8300 (reg);
else if (!TARGET_NORMAL_MODE)
x = gen_push_h8300hs_advanced (reg);
else
x = gen_push_h8300hs_normal (reg);
- x = emit_insn (x);
+ x = F (emit_insn (x));
REG_NOTES (x) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, 0);
}
/* Emit an insn to pop register RN. */
static void
@@ -631,13 +662,13 @@ pop (int rn)
static void
h8300_push_pop (int regno, int nregs, int pop_p, int return_p)
{
int i, j;
rtvec vec;
- rtx sp, offset;
+ rtx sp, offset, x;
/* See whether we can use a simple push or pop. */
if (!return_p && nregs == 1)
{
if (pop_p)
pop (regno);
@@ -682,13 +713,16 @@ h8300_push_pop (int regno, int nregs, in
/* Add the stack adjustment. */
offset = GEN_INT ((pop_p ? nregs : -nregs) * 4);
RTVEC_ELT (vec, i + j) = gen_rtx_SET (VOIDmode, sp,
gen_rtx_PLUS (Pmode, sp, offset));
- emit_insn (gen_rtx_PARALLEL (VOIDmode, vec));
+ x = gen_rtx_PARALLEL (VOIDmode, vec);
+ if (!pop_p)
+ x = Fpa (x);
+ emit_insn (x);
}
/* Return true if X has the value sp + OFFSET. */
static int
h8300_stack_offset_p (rtx x, int offset)
@@ -817,13 +851,13 @@ h8300_expand_prologue (void)
emit_insn (gen_monitor_prologue ());
if (frame_pointer_needed)
{
/* Push fp. */
push (HARD_FRAME_POINTER_REGNUM);
- emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx);
+ F (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx));
}
/* Push the rest of the registers in ascending order. */
saved_regs = compute_saved_regs ();
for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno += n_regs)
{
Index: h8300.h
===================================================================
--- h8300.h (revision 152793)
+++ h8300.h (working copy)
@@ -144,12 +144,23 @@ extern const char * const *h8_reg_names;
#define TARGET_DEFAULT (MASK_QUICKCALL)
#endif
/* Show we can debug even without a frame pointer. */
/* #define CAN_DEBUG_WITHOUT_FP */
+/* We want dwarf2 info available to gdb... */
+#define DWARF2_DEBUGGING_INFO 1
+/* ... but we don't actually support full dwarf2 EH. */
+#define MUST_USE_SJLJ_EXCEPTIONS 1
+
+/* The return address is pushed on the stack. */
+#define INCOMING_RETURN_ADDR_RTX gen_rtx_MEM (Pmode, gen_rtx_REG (Pmode, STACK_POINTER_REGNUM))
+#define INCOMING_FRAME_SP_OFFSET (POINTER_SIZE / 8)
+
+#define DWARF_CIE_DATA_ALIGNMENT 2
+
/* Define this if addresses of constant functions
shouldn't be put through pseudo regs where they can be cse'd.
Desirable on machines where ordinary constants are expensive
but a CALL with constant address is cheap.
Calls through a register are cheaper than calls to named