From c14afa1927f09e7690942d9e0eeb2b32a0458cc9 Mon Sep 17 00:00:00 2001 From: hp Date: Fri, 13 May 2005 17:08:29 +0000 Subject: [PATCH] Replace calls to abort in CRIS port. * config/cris/cris.h (CRIS_ASSERT): New macro. * config/cris/cris.md ("*movsi_internal"): Use CRIS_ASSERT and internal_error instead of abort. ("movsi"): Ditto. Unquote preparation statement section. * config/cris/cris.c (ASSERT_PLT_UNSPEC): Define in terms of CRIS_ASSERT. ("call", "call_value"): Ditto, but use gcc_assert where appropriate. Tweak comments. (cris_op_str): Call internal_error, not abort. (cris_print_operand): Tweak "abort" reference to "die" in comment. (cris_initial_elimination_offset): Call gcc_unreachable, not abort. (cris_notice_update_cc): Call internal_error, not abort. (cris_expand_return, cris_expand_prologue, cris_gen_movem_load) (cris_emit_movem_store, cris_asm_output_symbol_ref) (cris_output_addr_const_extra): Use CRIS_ASSERT, don't call abort. (cris_symbol, cris_got_symbol): Use CRIS_ASSERT instead of ENABLE_CHECKING-guarded abort call. (cris_split_movdx): Use CRIS_ASSERT instead of abort with test. Use internal_error at end of test-chain. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99669 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 23 +++++++++++++++++++ gcc/config/cris/cris.c | 60 +++++++++++++++++-------------------------------- gcc/config/cris/cris.h | 5 +++++ gcc/config/cris/cris.md | 43 +++++++++++++---------------------- 4 files changed, 65 insertions(+), 66 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eff05d4..d02adcd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2005-05-13 Hans-Peter Nilsson + + Replace calls to abort in CRIS port. + * config/cris/cris.h (CRIS_ASSERT): New macro. + * config/cris/cris.md ("*movsi_internal"): Use CRIS_ASSERT and + internal_error instead of abort. + ("movsi"): Ditto. Unquote preparation statement section. + * config/cris/cris.c (ASSERT_PLT_UNSPEC): Define in terms of + CRIS_ASSERT. + ("call", "call_value"): Ditto, but use gcc_assert where + appropriate. Tweak comments. + (cris_op_str): Call internal_error, not abort. + (cris_print_operand): Tweak "abort" reference to "die" in comment. + (cris_initial_elimination_offset): Call gcc_unreachable, not abort. + (cris_notice_update_cc): Call internal_error, not abort. + (cris_expand_return, cris_expand_prologue, cris_gen_movem_load) + (cris_emit_movem_store, cris_asm_output_symbol_ref) + (cris_output_addr_const_extra): Use CRIS_ASSERT, don't call abort. + (cris_symbol, cris_got_symbol): Use CRIS_ASSERT instead of + ENABLE_CHECKING-guarded abort call. + (cris_split_movdx): Use CRIS_ASSERT instead of abort with test. + Use internal_error at end of test-chain. + 2005-05-13 J"orn Rennecke PR rtl-optimization/20769: diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index f9a7d1e..81e3ce6 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -51,14 +51,10 @@ Boston, MA 02111-1307, USA. */ #define ADDITIVE_SIZE_MODIFIER(size) \ ((size) <= 63 ? "q" : (size) <= 255 ? "u.b" : (size) <= 65535 ? "u.w" : ".d") -#define ASSERT_PLT_UNSPEC(x) \ - do \ - { \ - if (XINT (x, 1) != CRIS_UNSPEC_PLT \ - || (GET_CODE (XVECEXP (x, 0, 0)) != SYMBOL_REF \ - && GET_CODE (XVECEXP (x, 0, 0)) != LABEL_REF)) \ - abort (); \ - } while (0) +#define ASSERT_PLT_UNSPEC(x) \ + CRIS_ASSERT (XINT (x, 1) == CRIS_UNSPEC_PLT \ + && ((GET_CODE (XVECEXP (x, 0, 0)) == SYMBOL_REF) \ + || GET_CODE (XVECEXP (x, 0, 0)) == LABEL_REF)) #define LOSE_AND_RETURN(msgid, x) \ do \ @@ -448,7 +444,7 @@ cris_op_str (rtx x) an operator, for immediate output. If that ever happens for MULT, we need to apply TARGET_MUL_BUG in the caller. Make sure we notice. */ - abort (); + internal_error ("MULT case in cris_op_str"); break; case DIV: @@ -809,7 +805,7 @@ cris_print_operand (FILE *file, rtx x, int code) case 'z': /* Const_int: print b for -127 <= x <= 255, - w for -32768 <= x <= 65535, else abort. */ + w for -32768 <= x <= 65535, else die. */ if (GET_CODE (x) != CONST_INT || INTVAL (x) < -32768 || INTVAL (x) > 65535) LOSE_AND_RETURN ("invalid operand for 'z' modifier", x); @@ -1216,7 +1212,7 @@ cris_initial_elimination_offset (int fromreg, int toreg) && toreg == STACK_POINTER_REGNUM) return ap_fp_offset + fp_sp_offset - 4; - abort (); + gcc_unreachable (); } /* This function looks into the pattern to see how this insn affects @@ -1480,8 +1476,7 @@ cris_notice_update_cc (rtx exp, rtx insn) break; default: - /* Unknown cc_attr value. */ - abort (); + internal_error ("Unknown cc_attr value"); } CC_STATUS_INIT; @@ -1533,9 +1528,8 @@ cris_expand_return (bool on_stack) to check that it doesn't change half-way through. */ emit_jump_insn (gen_rtx_RETURN (VOIDmode)); - if ((cfun->machine->return_type == CRIS_RETINSN_RET && on_stack) - || (cfun->machine->return_type == CRIS_RETINSN_JUMP && !on_stack)) - abort (); + CRIS_ASSERT (cfun->machine->return_type != CRIS_RETINSN_RET || !on_stack); + CRIS_ASSERT (cfun->machine->return_type != CRIS_RETINSN_JUMP || on_stack); cfun->machine->return_type = on_stack ? CRIS_RETINSN_JUMP : CRIS_RETINSN_RET; @@ -1933,10 +1927,7 @@ cris_symbol (rtx x) int cris_gotless_symbol (rtx x) { -#ifdef ENABLE_CHECKING - if (!flag_pic) - abort (); -#endif + CRIS_ASSERT (flag_pic); switch (GET_CODE (x)) { @@ -1996,10 +1987,7 @@ cris_gotless_symbol (rtx x) int cris_got_symbol (rtx x) { -#ifdef ENABLE_CHECKING - if (!flag_pic) - abort (); -#endif + CRIS_ASSERT (flag_pic); switch (GET_CODE (x)) { @@ -2320,8 +2308,7 @@ cris_split_movdx (rtx *operands) /* We used to have to handle (SUBREG (MEM)) here, but that should no longer happen; after reload there are no SUBREGs any more, and we're only called after reload. */ - if (GET_CODE (dest) == SUBREG || GET_CODE (src) == SUBREG) - abort (); + CRIS_ASSERT (GET_CODE (dest) != SUBREG && GET_CODE (src) != SUBREG); start_sequence (); if (GET_CODE (dest) == REG) @@ -2412,7 +2399,7 @@ cris_split_movdx (rtx *operands) } } else - abort (); + internal_error ("Unknown src"); } /* Reg-to-mem copy or clear mem. */ else if (GET_CODE (dest) == MEM @@ -2454,7 +2441,7 @@ cris_split_movdx (rtx *operands) } else - abort (); + internal_error ("Unknown dest"); val = get_insns (); end_sequence (); @@ -2482,8 +2469,7 @@ cris_expand_prologue (void) if (!TARGET_PROLOGUE_EPILOGUE) return; - if (size < 0) - abort (); + CRIS_ASSERT (size >= 0); /* Align the size to what's best for the CPU model. */ if (TARGET_STACK_ALIGN) @@ -2930,8 +2916,7 @@ cris_gen_movem_load (rtx src, rtx nregs_rtx, int nprefix) if (GET_CODE (srcreg) == POST_INC) srcreg = XEXP (srcreg, 0); - if (!REG_P (srcreg)) - abort (); + CRIS_ASSERT (REG_P (srcreg)); /* Don't use movem for just one insn. The insns are equivalent except for the pipeline hazard (on v32); movem does not forward the loaded @@ -2987,8 +2972,7 @@ cris_emit_movem_store (rtx dest, rtx nregs_rtx, int increment, if (GET_CODE (destreg) == POST_INC || GET_CODE (destreg) == PLUS) destreg = XEXP (destreg, 0); - if (!REG_P (destreg)) - abort (); + CRIS_ASSERT (REG_P (destreg)); /* Don't use movem for just one insn. The insns are equivalent except for the pipeline hazard (on v32); movem does not forward the loaded @@ -3129,8 +3113,8 @@ cris_asm_output_symbol_ref (FILE *file, rtx x) } else if (cris_got_symbol (x)) { - if (cris_pic_sympart_only) - abort (); + CRIS_ASSERT (!cris_pic_sympart_only); + fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]); assemble_name (file, XSTR (x, 0)); @@ -3193,9 +3177,7 @@ cris_output_addr_const_extra (FILE *file, rtx x) } else { - if (TARGET_AVOID_GOTPLT) - /* We shouldn't get here. */ - abort (); + CRIS_ASSERT (!TARGET_AVOID_GOTPLT); fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]); assemble_name (file, XSTR (x, 0)); diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index f518238..797d42f 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -38,6 +38,11 @@ Boston, MA 02111-1307, USA. */ settings not repeated below. This file contains general CRIS definitions and definitions for the cris-*-elf subtarget. */ +/* We don't want to use gcc_assert for everything, as that can be + compiled out. */ +#define CRIS_ASSERT(x) \ + do { if (!(x)) internal_error ("CRIS-port assertion failed: " #x); } while (0) + /* Replacement for REG_P since it does not match SUBREGs. Happens for testcase Axis-20000320 with gcc-2.9x. */ #define REG_S_P(x) \ diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md index 7c56727..9e6818b 100644 --- a/gcc/config/cris/cris.md +++ b/gcc/config/cris/cris.md @@ -962,7 +962,6 @@ (match_operand:SI 0 "nonimmediate_operand" "") (match_operand:SI 1 "cris_general_operand_or_symbol" ""))] "" - " { /* If the output goes to a MEM, make sure we have zero or a register as input. */ @@ -986,8 +985,7 @@ do, and for the patterns we generate. */ if (! REG_S_P (operands[0])) { - if (no_new_pseudos) - abort (); + CRIS_ASSERT (!no_new_pseudos); operands[1] = force_reg (SImode, operands[1]); } else @@ -1017,18 +1015,18 @@ rtx sym = get_related_value (operands[1]); HOST_WIDE_INT offs = get_integer_term (operands[1]); - if (sym == NULL_RTX || offs == 0) - abort (); + CRIS_ASSERT (sym != NULL_RTX && offs != 0); + emit_move_insn (operands[0], sym); if (expand_binop (SImode, add_optab, operands[0], GEN_INT (offs), operands[0], 0, OPTAB_LIB_WIDEN) != operands[0]) - abort (); + internal_error ("expand_binop failed in movsi"); DONE; } } } -}") +}) (define_insn "*movsi_internal" [(set @@ -1103,8 +1101,7 @@ /* We clobber cc0 rather than set it to GOT. Should not matter, though. */ CC_STATUS_INIT; - if (REGNO (operands[0]) != PIC_OFFSET_TABLE_REGNUM) - abort (); + CRIS_ASSERT (REGNO (operands[0]) == PIC_OFFSET_TABLE_REGNUM); return \"move.d $pc,%0\;sub.d .:GOTOFF,%0\"; } @@ -3931,24 +3928,20 @@ (match_operand 1 "general_operand" "")) (clobber (reg:SI CRIS_SRP_REGNUM))])] "" - " { rtx op0; - if (GET_CODE (operands[0]) != MEM) - abort (); + gcc_assert (GET_CODE (operands[0]) == MEM); if (flag_pic) { op0 = XEXP (operands[0], 0); /* It might be that code can be generated that jumps to 0 (or to a - specific address). Don't abort on that. At least there's a - testcase. */ + specific address). Don't die on that. (There is a testcase.) */ if (CONSTANT_ADDRESS_P (op0) && GET_CODE (op0) != CONST_INT) { - if (no_new_pseudos) - abort (); + CRIS_ASSERT (!no_new_pseudos); /* For local symbols (non-PLT), get the plain symbol reference into a register. For symbols that can be PLT, make them PLT. */ @@ -3964,12 +3957,12 @@ gen_rtvec (1, op0), CRIS_UNSPEC_PLT))); else - abort (); + internal_error ("Unidentifiable op0"); operands[0] = replace_equiv_address (operands[0], op0); } } -}") +}) ;; Accept *anything* as operand 1. Accept operands for operand 0 in ;; order of preference. @@ -3998,24 +3991,20 @@ (match_operand 2 "" ""))) (clobber (reg:SI CRIS_SRP_REGNUM))])] "" - " { rtx op1; - if (GET_CODE (operands[1]) != MEM) - abort (); + gcc_assert (GET_CODE (operands[1]) == MEM); if (flag_pic) { op1 = XEXP (operands[1], 0); /* It might be that code can be generated that jumps to 0 (or to a - specific address). Don't abort on that. At least there's a - testcase. */ + specific address). Don't die on that. (There is a testcase.) */ if (CONSTANT_ADDRESS_P (op1) && GET_CODE (op1) != CONST_INT) { - if (no_new_pseudos) - abort (); + CRIS_ASSERT (!no_new_pseudos); if (cris_gotless_symbol (op1)) op1 = force_reg (Pmode, op1); @@ -4029,12 +4018,12 @@ gen_rtvec (1, op1), CRIS_UNSPEC_PLT))); else - abort (); + internal_error ("Unidentifiable op0"); operands[1] = replace_equiv_address (operands[1], op1); } } -}") +}) ;; Accept *anything* as operand 2. The validity other than "general" of ;; operand 0 will be checked elsewhere. Accept operands for operand 1 in -- 2.7.4