From ff050c66b18d8768b57b0c99f824e9b82e569ccb Mon Sep 17 00:00:00 2001 From: Matthew Fortune Date: Thu, 4 Sep 2014 08:32:05 +0000 Subject: [PATCH] Add target hook to override DWARF2 frame register size gcc/ * target.def (TARGET_DWARF_FRAME_REG_MODE): New target hook. * targhooks.c (default_dwarf_frame_reg_mode): New function. * targhooks.h (default_dwarf_frame_reg_mode): New prototype. * doc/tm.texi.in (TARGET_DWARF_FRAME_REG_MODE): Document. * doc/tm.texi: Regenerate. * dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Abstract mode selection logic to default_dwarf_frame_reg_mode. From-SVN: r214898 --- gcc/ChangeLog | 10 ++++++++++ gcc/doc/tm.texi | 7 +++++++ gcc/doc/tm.texi.in | 2 ++ gcc/dwarf2cfi.c | 4 +--- gcc/target.def | 11 +++++++++++ gcc/targhooks.c | 13 +++++++++++++ gcc/targhooks.h | 1 + 7 files changed, 45 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9ae222bce63..94cf799dec7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-09-03 Matthew Fortune + + * target.def (TARGET_DWARF_FRAME_REG_MODE): New target hook. + * targhooks.c (default_dwarf_frame_reg_mode): New function. + * targhooks.h (default_dwarf_frame_reg_mode): New prototype. + * doc/tm.texi.in (TARGET_DWARF_FRAME_REG_MODE): Document. + * doc/tm.texi: Regenerate. + * dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Abstract mode + selection logic to default_dwarf_frame_reg_mode. + 2014-09-03 Marek Polacek * doc/invoke.texi: Document that -Wlogical-not-parentheses is enabled diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 0c44d518fa0..94964771d52 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -8871,6 +8871,13 @@ register in Dwarf. Otherwise, this hook should return @code{NULL_RTX}. If not defined, the default is to return @code{NULL_RTX}. @end deftypefn +@deftypefn {Target Hook} {enum machine_mode} TARGET_DWARF_FRAME_REG_MODE (int @var{regno}) +Given a register, this hook should return the mode which the +corresponding Dwarf frame register should have. This is normally +used to return a smaller mode than the raw mode to prevent call +clobbered parts of a register altering the frame register size +@end deftypefn + @deftypefn {Target Hook} void TARGET_INIT_DWARF_REG_SIZES_EXTRA (tree @var{address}) If some registers are represented in Dwarf-2 unwind information in multiple pieces, define this hook to fill in information about the diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 7a63353b4ea..152d37d8f55 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -6594,6 +6594,8 @@ the target supports DWARF 2 frame unwind information. @hook TARGET_DWARF_REGISTER_SPAN +@hook TARGET_DWARF_FRAME_REG_MODE + @hook TARGET_INIT_DWARF_REG_SIZES_EXTRA @hook TARGET_ASM_TTYPE diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c index f30274e1471..b1659dd2777 100644 --- a/gcc/dwarf2cfi.c +++ b/gcc/dwarf2cfi.c @@ -271,11 +271,9 @@ expand_builtin_init_dwarf_reg_sizes (tree address) if (rnum < DWARF_FRAME_REGISTERS) { HOST_WIDE_INT offset = rnum * GET_MODE_SIZE (mode); - enum machine_mode save_mode = reg_raw_mode[i]; HOST_WIDE_INT size; + enum machine_mode save_mode = targetm.dwarf_frame_reg_mode (i); - if (HARD_REGNO_CALL_PART_CLOBBERED (i, save_mode)) - save_mode = choose_hard_reg_mode (i, 1, true); if (dnum == DWARF_FRAME_RETURN_COLUMN) { if (save_mode == VOIDmode) diff --git a/gcc/target.def b/gcc/target.def index e7212ea875d..29285f2cf7f 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3218,6 +3218,17 @@ If not defined, the default is to return @code{NULL_RTX}.", rtx, (rtx reg), hook_rtx_rtx_null) +/* Given a register return the mode of the corresponding DWARF frame + register. */ +DEFHOOK +(dwarf_frame_reg_mode, + "Given a register, this hook should return the mode which the\n\ +corresponding Dwarf frame register should have. This is normally\n\ +used to return a smaller mode than the raw mode to prevent call\n\ +clobbered parts of a register altering the frame register size", + enum machine_mode, (int regno), + default_dwarf_frame_reg_mode) + /* If expand_builtin_init_dwarf_reg_sizes needs to fill in table entries not corresponding directly to registers below FIRST_PSEUDO_REGISTER, this hook should generate the necessary diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 59ba9a7f7f6..61d19e4236f 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1456,6 +1456,19 @@ default_debug_unwind_info (void) return UI_NONE; } +/* Determine the correct mode for a Dwarf frame register that represents + register REGNO. */ + +enum machine_mode +default_dwarf_frame_reg_mode (int regno) +{ + enum machine_mode save_mode = reg_raw_mode[regno]; + + if (HARD_REGNO_CALL_PART_CLOBBERED (regno, save_mode)) + save_mode = choose_hard_reg_mode (regno, 1, true); + return save_mode; +} + /* To be used by targets where reg_raw_mode doesn't return the right mode for registers used in apply_builtin_return and apply_builtin_arg. */ diff --git a/gcc/targhooks.h b/gcc/targhooks.h index bbc9a82e147..0a1f6e9f6a0 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -194,6 +194,7 @@ extern int default_label_align_max_skip (rtx); extern int default_jump_align_max_skip (rtx); extern section * default_function_section(tree decl, enum node_frequency freq, bool startup, bool exit); +extern enum machine_mode default_dwarf_frame_reg_mode (int); extern enum machine_mode default_get_reg_raw_mode (int); extern bool default_keep_leaf_when_profiled (); -- 2.30.2