From: David Miller Date: Thu, 5 Jun 2003 16:31:49 +0000 (-0700) Subject: optabs.c (HAVE_conditional_trap): Provide default. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=842a431a9afc461050e98fe241d036232713cfaf;p=gcc.git optabs.c (HAVE_conditional_trap): Provide default. * optabs.c (HAVE_conditional_trap): Provide default. (gen_conditional_trap): Likewise. (init_optabs): Merge init_traps. (gen_cond_trap): Use prepare_operand. Restructure and avoid ifdef. * gcc.c-torture/compile/20030605-1.c: New. Co-Authored-By: Richard Henderson From-SVN: r67497 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1a295ba5b6c..1b1ad9ac566 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2003-06-05 David Miller + Richard Henderson + + * optabs.c (HAVE_conditional_trap): Provide default. + (gen_conditional_trap): Likewise. + (init_optabs): Merge init_traps. + (gen_cond_trap): Use prepare_operand. Restructure and avoid ifdef. + Thu Jun 5 14:59:44 CEST 2003 Jan Hubicka * combine.c (simplify_if_then_else): (IF_THEN_ELSE (NE REG 0) (0) (8)) diff --git a/gcc/optabs.c b/gcc/optabs.c index c693e80079a..8b7f3ea0481 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -88,6 +88,11 @@ enum insn_code setcc_gen_code[NUM_RTX_CODE]; enum insn_code movcc_gen_code[NUM_MACHINE_MODES]; #endif +/* The insn generating function can not take an rtx_code argument. + TRAP_RTX is used as an rtx argument. Its code is replaced with + the code to be used in the trap insn and all other fields are ignored. */ +static GTY(()) rtx trap_rtx; + static int add_equal_note PARAMS ((rtx, rtx, enum rtx_code, rtx, rtx)); static rtx widen_operand PARAMS ((rtx, enum machine_mode, enum machine_mode, int, int)); @@ -114,9 +119,6 @@ static inline optab init_optabv PARAMS ((enum rtx_code)); static void init_libfuncs PARAMS ((optab, int, int, const char *, int)); static void init_integral_libfuncs PARAMS ((optab, const char *, int)); static void init_floating_libfuncs PARAMS ((optab, const char *, int)); -#ifdef HAVE_conditional_trap -static void init_traps PARAMS ((void)); -#endif static void emit_cmp_and_jump_insn_1 PARAMS ((rtx, rtx, enum machine_mode, enum rtx_code, int, rtx)); static void prepare_float_lib_cmp PARAMS ((rtx *, rtx *, enum rtx_code *, @@ -128,6 +130,11 @@ static rtx expand_vector_unop PARAMS ((enum machine_mode, optab, rtx, rtx, int)); static rtx widen_clz PARAMS ((enum machine_mode, rtx, rtx)); static rtx expand_parity PARAMS ((enum machine_mode, rtx, rtx)); + +#ifndef HAVE_conditional_trap +#define HAVE_conditional_trap 0 +#define gen_conditional_trap(a,b) (abort (), NULL_RTX) +#endif /* Add a REG_EQUAL note to the last insn in INSNS. TARGET is being set to the result of operation CODE applied to OP0 (and OP1 if it is a binary @@ -5806,9 +5813,8 @@ init_optabs () gcov_flush_libfunc = init_one_libfunc ("__gcov_flush"); gcov_init_libfunc = init_one_libfunc ("__gcov_init"); -#ifdef HAVE_conditional_trap - init_traps (); -#endif + if (HAVE_conditional_trap) + trap_rtx = gen_rtx_fmt_ee (EQ, VOIDmode, NULL_RTX, NULL_RTX); #ifdef INIT_TARGET_OPTABS /* Allow the target to add more libcalls or rename some, etc. */ @@ -5816,24 +5822,6 @@ init_optabs () #endif } -static GTY(()) rtx trap_rtx; - -#ifdef HAVE_conditional_trap -/* The insn generating function can not take an rtx_code argument. - TRAP_RTX is used as an rtx argument. Its code is replaced with - the code to be used in the trap insn and all other fields are - ignored. */ - -static void -init_traps () -{ - if (HAVE_conditional_trap) - { - trap_rtx = gen_rtx_fmt_ee (EQ, VOIDmode, NULL_RTX, NULL_RTX); - } -} -#endif - /* Generate insns to trap with code TCODE if OP1 and OP2 satisfy condition CODE. Return 0 on failure. */ @@ -5843,30 +5831,34 @@ gen_cond_trap (code, op1, op2, tcode) rtx op1, op2 ATTRIBUTE_UNUSED, tcode ATTRIBUTE_UNUSED; { enum machine_mode mode = GET_MODE (op1); + enum insn_code icode; + rtx insn; + + if (!HAVE_conditional_trap) + return 0; if (mode == VOIDmode) return 0; -#ifdef HAVE_conditional_trap - if (HAVE_conditional_trap - && cmp_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing) + icode = cmp_optab->handlers[(int) mode].insn_code; + if (icode == CODE_FOR_nothing) + return 0; + + start_sequence (); + op1 = prepare_operand (icode, op1, 0, mode, mode, 0); + op2 = prepare_operand (icode, op2, 0, mode, mode, 0); + emit_insn (GEN_FCN (icode) (op1, op2)); + + PUT_CODE (trap_rtx, code); + insn = gen_conditional_trap (trap_rtx, tcode); + if (insn) { - rtx insn; - start_sequence (); - emit_insn (GEN_FCN (cmp_optab->handlers[(int) mode].insn_code) (op1, op2)); - PUT_CODE (trap_rtx, code); - insn = gen_conditional_trap (trap_rtx, tcode); - if (insn) - { - emit_insn (insn); - insn = get_insns (); - } - end_sequence (); - return insn; + emit_insn (insn); + insn = get_insns (); } -#endif + end_sequence (); - return 0; + return insn; } #include "gt-optabs.h" diff --git a/gcc/testsuite/gcc.c-torture/compile/20030605-1.c b/gcc/testsuite/gcc.c-torture/compile/20030605-1.c new file mode 100644 index 00000000000..f5e102318b2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20030605-1.c @@ -0,0 +1,12 @@ +/* Test for proper preparation of the comparison operands for + generation of a conditional trap. Produced unrecognizable + rtl on Sparc. */ + +struct blah { char *b_data; }; + +void set_bh_page(struct blah *bh, unsigned long offset) +{ + if ((1UL << 12 ) <= offset) + __builtin_trap() ; + bh->b_data = (char *)offset; +}