From 62164eb49e501141f015c71410f625b2bf133570 Mon Sep 17 00:00:00 2001 From: "J\"orn Rennecke" Date: Wed, 18 Aug 2004 17:44:28 +0000 Subject: [PATCH] sh.h (CONDITIONAL_REGISTER_USAGE): Don't exclude fixed registers from call_used_regs. * sh.h (CONDITIONAL_REGISTER_USAGE): Don't exclude fixed registers from call_used_regs. Update call_really_used_regs. (CALL_REALLY_USED_REGISTERS): Define. * sh.c (output_stack_adjust, shmedia_target_regs_stack_space): Replace call_used_regs with call_really_used_regs. (calc_live_regs, sh_media_register_for_return): Likewise. (sh5_schedule_saves, sh_expand_prologue, reg_unused_after): Likewise. * sh.md (return_media): Likewise. From-SVN: r86195 --- gcc/ChangeLog | 11 +++++++++++ gcc/config/sh/sh.c | 24 +++++++++++++----------- gcc/config/sh/sh.h | 25 ++++++++++++++++++------- gcc/config/sh/sh.md | 2 +- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 52b92b77db1..6dc33062d4a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2004-08-18 J"orn Rennecke + + * sh.h (CONDITIONAL_REGISTER_USAGE): Don't exclude fixed registers + from call_used_regs. Update call_really_used_regs. + (CALL_REALLY_USED_REGISTERS): Define. + * sh.c (output_stack_adjust, shmedia_target_regs_stack_space): + Replace call_used_regs with call_really_used_regs. + (calc_live_regs, sh_media_register_for_return): Likewise. + (sh5_schedule_saves, sh_expand_prologue, reg_unused_after): Likewise. + * sh.md (return_media): Likewise. + 2004-08-18 Andrew Pinski * config/darwin.c (machopic_legitimize_pic_address): Only set MEM_READONLY_P diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 950b096be60..6cfcdf94e17 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -4821,7 +4821,7 @@ output_stack_adjust (int size, rtx reg, int epilogue_p, to handle this case, so just abort when we see it. */ if (epilogue_p < 0 || current_function_interrupt - || ! call_used_regs[temp] || fixed_regs[temp]) + || ! call_really_used_regs[temp] || fixed_regs[temp]) temp = -1; if (temp < 0 && ! current_function_interrupt && (TARGET_SHMEDIA || epilogue_p >= 0)) @@ -5051,7 +5051,7 @@ shmedia_target_regs_stack_space (HARD_REG_SET *live_regs_mask) int interrupt_handler = sh_cfun_interrupt_handler_p (); for (reg = LAST_TARGET_REG; reg >= FIRST_TARGET_REG; reg--) - if ((! call_used_regs[reg] || interrupt_handler) + if ((! call_really_used_regs[reg] || interrupt_handler) && ! TEST_HARD_REG_BIT (*live_regs_mask, reg)) /* Leave space to save this target register on the stack, in case target register allocation wants to use it. */ @@ -5111,7 +5111,8 @@ calc_live_regs (HARD_REG_SET *live_regs_mask) else if ((TARGET_SH4 || TARGET_SH2A_DOUBLE) && TARGET_FMOVD && TARGET_FPU_SINGLE) for (count = 0, reg = FIRST_FP_REG; reg <= LAST_FP_REG; reg += 2) if (regs_ever_live[reg] && regs_ever_live[reg+1] - && (! call_used_regs[reg] || (interrupt_handler && ! pragma_trapa)) + && (! call_really_used_regs[reg] + || (interrupt_handler && ! pragma_trapa)) && ++count > 2) { target_flags &= ~FPU_SINGLE_BIT; @@ -5152,8 +5153,9 @@ calc_live_regs (HARD_REG_SET *live_regs_mask) : (interrupt_handler && ! pragma_trapa) ? (/* Need to save all the regs ever live. */ (regs_ever_live[reg] - || (call_used_regs[reg] - && (! fixed_regs[reg] || reg == MACH_REG || reg == MACL_REG) + || (call_really_used_regs[reg] + && (! fixed_regs[reg] || reg == MACH_REG || reg == MACL_REG + || reg == PIC_OFFSET_TABLE_REGNUM) && has_call) || (has_call && REGISTER_NATURAL_MODE (reg) == SImode && (GENERAL_REGISTER_P (reg) || TARGET_REGISTER_P (reg)))) @@ -5167,7 +5169,7 @@ calc_live_regs (HARD_REG_SET *live_regs_mask) && flag_pic && current_function_args_info.call_cookie && reg == (int) PIC_OFFSET_TABLE_REGNUM) - || (regs_ever_live[reg] && ! call_used_regs[reg]) + || (regs_ever_live[reg] && ! call_really_used_regs[reg]) || (current_function_calls_eh_return && (reg == (int) EH_RETURN_DATA_REGNO (0) || reg == (int) EH_RETURN_DATA_REGNO (1) @@ -5207,7 +5209,7 @@ calc_live_regs (HARD_REG_SET *live_regs_mask) && TARGET_SAVE_ALL_TARGET_REGS && shmedia_space_reserved_for_target_registers) for (reg = LAST_TARGET_REG; reg >= FIRST_TARGET_REG; reg--) - if ((! call_used_regs[reg] || interrupt_handler) + if ((! call_really_used_regs[reg] || interrupt_handler) && ! TEST_HARD_REG_BIT (*live_regs_mask, reg)) { SET_HARD_REG_BIT (*live_regs_mask, reg); @@ -5262,7 +5264,7 @@ sh_media_register_for_return (void) tr0_used = flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM]; for (regno = FIRST_TARGET_REG + tr0_used; regno <= LAST_TARGET_REG; regno++) - if (call_used_regs[regno] && ! regs_ever_live[regno]) + if (call_really_used_regs[regno] && ! regs_ever_live[regno]) return regno; return -1; @@ -5310,7 +5312,7 @@ sh5_schedule_saves (HARD_REG_SET *live_regs_mask, save_schedule *schedule, if (! current_function_interrupt) for (i = FIRST_GENERAL_REG; tmpx < MAX_TEMPS && i <= LAST_GENERAL_REG; i++) - if (call_used_regs[i] && ! fixed_regs[i] && i != PR_MEDIA_REG + if (call_really_used_regs[i] && ! fixed_regs[i] && i != PR_MEDIA_REG && ! FUNCTION_ARG_REGNO_P (i) && i != FIRST_RET_REG && ! (cfun->static_chain_decl != NULL && i == STATIC_CHAIN_REGNUM) @@ -5510,7 +5512,7 @@ sh_expand_prologue (void) save_entry *entry; int *tmp_pnt; - if (call_used_regs[R0_REG] && ! fixed_regs[R0_REG] + if (call_really_used_regs[R0_REG] && ! fixed_regs[R0_REG] && ! current_function_interrupt) r0 = gen_rtx_REG (Pmode, R0_REG); @@ -8005,7 +8007,7 @@ reg_unused_after (rtx reg, rtx insn) if (set == 0 && reg_overlap_mentioned_p (reg, PATTERN (insn))) return 0; - if (code == CALL_INSN && call_used_regs[REGNO (reg)]) + if (code == CALL_INSN && call_really_used_regs[REGNO (reg)]) return 1; } return 1; diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index a66129aef20..259efb06b25 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -106,8 +106,12 @@ do { \ fixed_regs[regno] = call_used_regs[regno] = 1; \ /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. */ \ if (TARGET_SH5) \ - call_used_regs[FIRST_GENERAL_REG + 8] \ - = call_used_regs[FIRST_GENERAL_REG + 9] = 1; \ + { \ + call_used_regs[FIRST_GENERAL_REG + 8] \ + = call_used_regs[FIRST_GENERAL_REG + 9] = 1; \ + call_really_used_regs[FIRST_GENERAL_REG + 8] \ + = call_really_used_regs[FIRST_GENERAL_REG + 9] = 1; \ + } \ if (TARGET_SHMEDIA) \ { \ regno_reg_class[FIRST_GENERAL_REG] = GENERAL_REGS; \ @@ -115,12 +119,15 @@ do { \ regno_reg_class[FIRST_FP_REG] = FP_REGS; \ } \ if (flag_pic) \ - fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ + { \ + fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ + call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ + } \ /* Renesas saves and restores mac registers on call. */ \ if (TARGET_HITACHI && ! TARGET_NOMACSAVE) \ { \ - call_used_regs[MACH_REG] = 0; \ - call_used_regs[MACL_REG] = 0; \ + call_really_used_regs[MACH_REG] = 0; \ + call_really_used_regs[MACL_REG] = 0; \ } \ for (regno = FIRST_FP_REG + (TARGET_LITTLE_ENDIAN != 0); \ regno <= LAST_FP_REG; regno += 2) \ @@ -128,12 +135,12 @@ do { \ if (TARGET_SHMEDIA) \ { \ for (regno = FIRST_TARGET_REG; regno <= LAST_TARGET_REG; regno ++)\ - if (! fixed_regs[regno] && call_used_regs[regno]) \ + if (! fixed_regs[regno] && call_really_used_regs[regno]) \ SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \ } \ else \ for (regno = FIRST_GENERAL_REG; regno <= LAST_GENERAL_REG; regno++) \ - if (! fixed_regs[regno] && call_used_regs[regno]) \ + if (! fixed_regs[regno] && call_really_used_regs[regno]) \ SET_HARD_REG_BIT (reg_class_contents[SIBCALL_REGS], regno); \ } while (0) @@ -1221,6 +1228,10 @@ extern char sh_additional_register_names[ADDREGNAMES_SIZE] \ 1, \ } +/* CONDITIONAL_REGISTER_USAGE might want to make a register call-used, yet + fixed, like PIC_OFFSET_TABLE_REGNUM. */ +#define CALL_REALLY_USED_REGISTERS CALL_USED_REGISTERS + /* Only the lower 32-bits of R10-R14 are guaranteed to be preserved across SHcompact function calls. We can't tell whether a called function is SHmedia or SHcompact, so we assume it may be when diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 45b48eb96d6..9354167d851 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -7311,7 +7311,7 @@ mov.l\\t1f,r0\\n\\ { rtx r18 = gen_rtx_REG (DImode, PR_MEDIA_REG); - if (! call_used_regs[TR0_REG] || fixed_regs[TR0_REG]) + if (! call_really_used_regs[TR0_REG] || fixed_regs[TR0_REG]) abort (); tr_regno = TR0_REG; tr = gen_rtx_REG (DImode, tr_regno); -- 2.30.2