This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Committed, CRIS: Replace calls to abort.
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 13 May 2005 20:19:39 +0200
- Subject: Committed, CRIS: Replace calls to abort.
I didn't like the proposed wholesale conversion to gcc_assert and
gcc_unreachable (*all* sanity checking being #definable out), so here's
what I committed. Some were clearly gcc_assert material, while others
were better kept as actual tests IMO. I wouldn't mind CRIS_ASSERT being
replaced with something to the effect of GCC_ALWAYS_ASSERT, but there
better not be an GCC_ALWAYS_NDEBUG equivalent. ;-)
There are no test-cases for any of the errors hitting, but at least I
tested that they *don't* hit, cross to cris-elf and cris-linux.
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.
("call", "call_value"): Ditto, but use gcc_assert where
appropriate. Tweak comments.
* config/cris/cris.c (ASSERT_PLT_UNSPEC): Define in terms of
CRIS_ASSERT.
(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.
Index: cris.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.c,v
retrieving revision 1.75
diff -p -u -r1.75 cris.c
--- cris.c 12 May 2005 23:36:46 -0000 1.75
+++ cris.c 13 May 2005 00:30:49 -0000
@@ -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, i
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 fro
&& 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_
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 nre
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,
}
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
}
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));
Index: cris.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.h,v
retrieving revision 1.91
diff -p -u -r1.91 cris.h
--- cris.h 23 Apr 2005 14:03:53 -0000 1.91
+++ cris.h 13 May 2005 00:30:49 -0000
@@ -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) \
Index: cris.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.md,v
retrieving revision 1.32
diff -p -u -r1.32 cris.md
--- cris.md 7 May 2005 19:37:15 -0000 1.32
+++ cris.md 13 May 2005 00:30:52 -0000
@@ -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
brgds, H-P