OSDN Git Service

* array.c: Don't include assert.h.
[pf3gnuchains/gcc-fork.git] / gcc / except.c
index c66ad32..b09ff83 100644 (file)
@@ -376,7 +376,7 @@ init_eh (void)
                         integer_type_node);
       DECL_FIELD_CONTEXT (f_cs) = sjlj_fc_type_node;
 
-      tmp = build_index_type (build_int_2 (4 - 1, 0));
+      tmp = build_index_type (build_int_cst (NULL_TREE, 4 - 1));
       tmp = build_array_type (lang_hooks.types.type_for_mode (word_mode, 1),
                              tmp);
       f_data = build_decl (FIELD_DECL, get_identifier ("__data"), tmp);
@@ -392,17 +392,17 @@ init_eh (void)
 
 #ifdef DONT_USE_BUILTIN_SETJMP
 #ifdef JMP_BUF_SIZE
-      tmp = build_int_2 (JMP_BUF_SIZE - 1, 0);
+      tmp = build_int_cst (NULL_TREE, JMP_BUF_SIZE - 1);
 #else
       /* Should be large enough for most systems, if it is not,
         JMP_BUF_SIZE should be defined with the proper value.  It will
         also tend to be larger than necessary for most systems, a more
         optimal port will define JMP_BUF_SIZE.  */
-      tmp = build_int_2 (FIRST_PSEUDO_REGISTER + 2 - 1, 0);
+      tmp = build_int_cst (NULL_TREE, FIRST_PSEUDO_REGISTER + 2 - 1);
 #endif
 #else
       /* builtin_setjmp takes a pointer to 5 words.  */
-      tmp = build_int_2 (5 * BITS_PER_WORD / POINTER_SIZE - 1, 0);
+      tmp = build_int_cst (NULL_TREE, 5 * BITS_PER_WORD / POINTER_SIZE - 1);
 #endif
       tmp = build_index_type (tmp);
       tmp = build_array_type (ptr_type_node, tmp);
@@ -460,8 +460,7 @@ gen_eh_region (enum eh_region_type type, struct eh_region *outer)
   struct eh_region *new;
 
 #ifdef ENABLE_CHECKING
-  if (! doing_eh (0))
-    abort ();
+  gcc_assert (doing_eh (0));
 #endif
 
   /* Insert a new blank region as a leaf in the tree.  */
@@ -626,7 +625,7 @@ get_exception_filter (struct function *fun)
   rtx filter = fun->eh->filter;
   if (fun == cfun && ! filter)
     {
-      filter = gen_reg_rtx (word_mode);
+      filter = gen_reg_rtx (targetm.eh_return_filter_mode ());
       fun->eh->filter = filter;
     }
   return filter;
@@ -688,8 +687,7 @@ resolve_one_fixup_region (struct eh_region *fixup)
          && cleanup->u.cleanup.exp == fixup->u.fixup.cleanup_exp)
        break;
     }
-  if (j > n)
-    abort ();
+  gcc_assert (j <= n);
 
   real = cleanup->outer;
   if (real && real->type == ERT_FIXUP)
@@ -811,14 +809,12 @@ remove_unreachable_regions (rtx insns)
 
       if (r->resume)
        {
-         if (uid_region_num[INSN_UID (r->resume)])
-           abort ();
+         gcc_assert (!uid_region_num[INSN_UID (r->resume)]);
          uid_region_num[INSN_UID (r->resume)] = i;
        }
       if (r->label)
        {
-         if (uid_region_num[INSN_UID (r->label)])
-           abort ();
+         gcc_assert (!uid_region_num[INSN_UID (r->label)]);
          uid_region_num[INSN_UID (r->label)] = i;
        }
     }
@@ -887,7 +883,7 @@ convert_from_eh_region_ranges_1 (rtx *pinsns, int *orig_sp, int cur)
   for (insn = *pinsns; insn ; insn = next)
     {
       next = NEXT_INSN (insn);
-      if (GET_CODE (insn) == NOTE)
+      if (NOTE_P (insn))
        {
          int kind = NOTE_LINE_NUMBER (insn);
          if (kind == NOTE_INSN_EH_REGION_BEG
@@ -928,7 +924,7 @@ convert_from_eh_region_ranges_1 (rtx *pinsns, int *orig_sp, int cur)
              /* Calls can always potentially throw exceptions, unless
                 they have a REG_EH_REGION note with a value of 0 or less.
                 Which should be the only possible kind so far.  */
-             && (GET_CODE (insn) == CALL_INSN
+             && (CALL_P (insn)
                  /* If we wanted exceptions for non-call insns, then
                     any may_trap_p instruction could throw.  */
                  || (flag_non_call_exceptions
@@ -942,8 +938,7 @@ convert_from_eh_region_ranges_1 (rtx *pinsns, int *orig_sp, int cur)
        }
     }
 
-  if (sp != orig_sp)
-    abort ();
+  gcc_assert (sp == orig_sp);
 }
 
 static void
@@ -1006,8 +1001,7 @@ add_ehl_entry (rtx label, struct eh_region *region)
      label.  After landing pad creation, the exception handlers may
      share landing pads.  This is ok, since maybe_remove_eh_handler
      only requires the 1-1 mapping before landing pad creation.  */
-  if (*slot && !cfun->eh->built_landing_pads)
-    abort ();
+  gcc_assert (!*slot || cfun->eh->built_landing_pads);
 
   *slot = entry;
 }
@@ -1104,7 +1098,7 @@ duplicate_eh_region_1 (struct eh_region *o, struct inline_remap *map)
       n->u.throw.type = o->u.throw.type;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 
   if (o->label)
@@ -1112,8 +1106,7 @@ duplicate_eh_region_1 (struct eh_region *o, struct inline_remap *map)
   if (o->resume)
     {
       n->resume = map->insn_map[INSN_UID (o->resume)];
-      if (n->resume == NULL)
-       abort ();
+      gcc_assert (n->resume);
     }
 
   return n;
@@ -1414,7 +1407,7 @@ assign_filter_values (void)
              for (;tp_node; tp_node = TREE_CHAIN (tp_node))
                {
                  int flt = add_ttypes_entry (ttypes, TREE_VALUE (tp_node));
-                 tree flt_node = build_int_2 (flt, 0);
+                 tree flt_node = build_int_cst (NULL_TREE, flt);
 
                  r->u.catch.filter_list
                    = tree_cons (NULL_TREE, flt_node, r->u.catch.filter_list);
@@ -1425,7 +1418,7 @@ assign_filter_values (void)
              /* Get a filter value for the NULL list also since it will need
                 an action record anyway.  */
              int flt = add_ttypes_entry (ttypes, NULL);
-             tree flt_node = build_int_2 (flt, 0);
+             tree flt_node = build_int_cst (NULL_TREE, flt);
 
              r->u.catch.filter_list
                = tree_cons (NULL_TREE, flt_node, r->u.catch.filter_list);
@@ -1464,7 +1457,7 @@ emit_to_new_bb_before (rtx seq, rtx insn)
     if (e->flags & EDGE_FALLTHRU)
       force_nonfallthru (e);
   last = emit_insn_before (seq, insn);
-  if (GET_CODE (last) == BARRIER)
+  if (BARRIER_P (last))
     last = PREV_INSN (last);
   bb = create_basic_block (seq, last, BLOCK_FOR_INSN (insn)->prev_bb);
   update_bb_for_insn (bb);
@@ -1526,7 +1519,8 @@ build_post_landing_pads (void)
                        emit_cmp_and_jump_insns
                          (cfun->eh->filter,
                           GEN_INT (tree_low_cst (TREE_VALUE (flt_node), 0)),
-                          EQ, NULL_RTX, word_mode, 0, c->label);
+                          EQ, NULL_RTX, 
+                          targetm.eh_return_filter_mode (), 0, c->label);
 
                        tp_node = TREE_CHAIN (tp_node);
                        flt_node = TREE_CHAIN (flt_node);
@@ -1558,7 +1552,8 @@ build_post_landing_pads (void)
 
          emit_cmp_and_jump_insns (cfun->eh->filter,
                                   GEN_INT (region->u.allowed.filter),
-                                  EQ, NULL_RTX, word_mode, 0, region->label);
+                                  EQ, NULL_RTX, 
+                                  targetm.eh_return_filter_mode (), 0, region->label);
 
          /* We delay the generation of the _Unwind_Resume until we generate
             landing pads.  We emit a marker here so as to get good control
@@ -1584,7 +1579,7 @@ build_post_landing_pads (void)
          break;
 
        default:
-         abort ();
+         gcc_unreachable ();
        }
     }
 }
@@ -1655,8 +1650,7 @@ connect_post_landing_pads (void)
       end_sequence ();
       barrier = emit_insn_before (seq, region->resume);
       /* Avoid duplicate barrier.  */
-      if (GET_CODE (barrier) != BARRIER)
-       abort ();
+      gcc_assert (BARRIER_P (barrier));
       delete_insn (barrier);
       delete_insn (region->resume);
 
@@ -1736,7 +1730,8 @@ dw2_build_landing_pads (void)
       emit_move_insn (cfun->eh->exc_ptr,
                      gen_rtx_REG (ptr_mode, EH_RETURN_DATA_REGNO (0)));
       emit_move_insn (cfun->eh->filter,
-                     gen_rtx_REG (word_mode, EH_RETURN_DATA_REGNO (1)));
+                     gen_rtx_REG (targetm.eh_return_filter_mode (), 
+                                  EH_RETURN_DATA_REGNO (1)));
 
       seq = get_insns ();
       end_sequence ();
@@ -1880,7 +1875,7 @@ sjlj_mark_call_sites (struct sjlj_lp_info *lp_info)
       rtx note, before, p;
 
       /* Reset value tracking at extended basic block boundaries.  */
-      if (GET_CODE (insn) == CODE_LABEL)
+      if (LABEL_P (insn))
        last_call_site = -2;
 
       if (! INSN_P (insn))
@@ -1892,7 +1887,7 @@ sjlj_mark_call_sites (struct sjlj_lp_info *lp_info)
          /* Calls (and trapping insns) without notes are outside any
             exception handling region in this function.  Mark them as
             no action.  */
-         if (GET_CODE (insn) == CALL_INSN
+         if (CALL_P (insn)
              || (flag_non_call_exceptions
                  && may_trap_p (PATTERN (insn))))
            this_call_site = -1;
@@ -1914,7 +1909,7 @@ sjlj_mark_call_sites (struct sjlj_lp_info *lp_info)
 
       /* Don't separate a call from it's argument loads.  */
       before = insn;
-      if (GET_CODE (insn) == CALL_INSN)
+      if (CALL_P (insn))
        before = find_first_parameter_load (insn, NULL_RTX);
 
       start_sequence ();
@@ -1991,7 +1986,7 @@ sjlj_emit_function_enter (rtx dispatch_label)
      can_throw_internal instructions.  */
 
   for (fn_begin = get_insns (); ; fn_begin = NEXT_INSN (fn_begin))
-    if (GET_CODE (fn_begin) == NOTE
+    if (NOTE_P (fn_begin)
        && (NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_FUNCTION_BEG
            || NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_BASIC_BLOCK))
       break;
@@ -2001,7 +1996,7 @@ sjlj_emit_function_enter (rtx dispatch_label)
     {
       rtx last = BB_END (ENTRY_BLOCK_PTR->succ->dest);
       for (; ; fn_begin = NEXT_INSN (fn_begin))
-       if ((GET_CODE (fn_begin) == NOTE
+       if ((NOTE_P (fn_begin)
             && NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_FUNCTION_BEG)
            || fn_begin == last)
          break;
@@ -2046,8 +2041,7 @@ sjlj_emit_function_exit (void)
       /* Figure out whether the place we are supposed to insert libcall
          is inside the last basic block or after it.  In the other case
          we need to emit to edge.  */
-      if (e->src->next_bb != EXIT_BLOCK_PTR)
-       abort ();
+      gcc_assert (e->src->next_bb == EXIT_BLOCK_PTR);
       for (insn = NEXT_INSN (BB_END (e->src)); insn; insn = NEXT_INSN (insn))
        if (insn == cfun->eh->sjlj_exit_after)
          break;
@@ -2056,7 +2050,7 @@ sjlj_emit_function_exit (void)
       else
        {
          insn = cfun->eh->sjlj_exit_after;
-         if (GET_CODE (insn) == CODE_LABEL)
+         if (LABEL_P (insn))
            insn = NEXT_INSN (insn);
          emit_insn_after (seq, insn);
        }
@@ -2179,8 +2173,6 @@ finish_eh_generation (void)
      connect many of the handlers, and then type information will not
      be effective.  Still, this is a win over previous implementations.  */
 
-  cleanup_cfg (CLEANUP_PRE_LOOP | CLEANUP_NO_INSN_DEL);
-
   /* These registers are used by the landing pads.  Make sure they
      have been generated.  */
   get_exception_pointer (cfun);
@@ -2219,7 +2211,6 @@ finish_eh_generation (void)
       if (eh)
        rtl_make_eh_edge (NULL, bb, BB_END (bb));
     }
-  cleanup_cfg (CLEANUP_PRE_LOOP | CLEANUP_NO_INSN_DEL);
 }
 \f
 static hashval_t
@@ -2258,8 +2249,7 @@ remove_exception_handler_label (rtx label)
   tmp.label = label;
   slot = (struct ehl_map_entry **)
     htab_find_slot (cfun->eh->exception_handler_label_map, &tmp, NO_INSERT);
-  if (! slot)
-    abort ();
+  gcc_assert (slot);
 
   htab_clear_slot (cfun->eh->exception_handler_label_map, (void **) slot);
 }
@@ -2330,8 +2320,7 @@ remove_eh_handler (struct eh_region *region)
           try->type == ERT_CATCH;
           try = try->next_peer)
        continue;
-      if (try->type != ERT_TRY)
-       abort ();
+      gcc_assert (try->type == ERT_TRY);
 
       next = region->u.catch.next_catch;
       prev = region->u.catch.prev_catch;
@@ -2642,10 +2631,11 @@ reachable_next_level (struct eh_region *region, tree type_thrown,
     case ERT_FIXUP:
     case ERT_UNKNOWN:
       /* Shouldn't see these here.  */
+      gcc_unreachable ();
       break;
+    default:
+      gcc_unreachable ();
     }
-
-  abort ();
 }
 
 /* Invoke CALLBACK on each region reachable from REGION_NUMBER.  */
@@ -2720,7 +2710,7 @@ reachable_handlers (rtx insn)
   rtx handlers = NULL;
   int region_number;
 
-  if (GET_CODE (insn) == JUMP_INSN
+  if (JUMP_P (insn)
       && GET_CODE (PATTERN (insn)) == RESX)
     {
       region_number = XINT (PATTERN (insn), 0);
@@ -2784,12 +2774,12 @@ can_throw_internal (rtx insn)
   if (! INSN_P (insn))
     return false;
 
-  if (GET_CODE (insn) == JUMP_INSN
+  if (JUMP_P (insn)
       && GET_CODE (PATTERN (insn)) == RESX
       && XINT (PATTERN (insn), 0) > 0)
     return can_throw_internal_1 (XINT (PATTERN (insn), 0));
 
-  if (GET_CODE (insn) == INSN
+  if (NONJUMP_INSN_P (insn)
       && GET_CODE (PATTERN (insn)) == SEQUENCE)
     insn = XVECEXP (PATTERN (insn), 0, 0);
 
@@ -2836,7 +2826,7 @@ can_throw_external (rtx insn)
   if (! INSN_P (insn))
     return false;
 
-  if (GET_CODE (insn) == INSN
+  if (NONJUMP_INSN_P (insn)
       && GET_CODE (PATTERN (insn)) == SEQUENCE)
     insn = XVECEXP (PATTERN (insn), 0, 0);
 
@@ -2848,7 +2838,7 @@ can_throw_external (rtx insn)
         assume it might throw.  Given that the front end and middle
         ends mark known NOTHROW functions, this isn't so wildly
         inaccurate.  */
-      return (GET_CODE (insn) == CALL_INSN
+      return (CALL_P (insn)
              || (flag_non_call_exceptions
                  && may_trap_p (PATTERN (insn))));
     }
@@ -2883,7 +2873,7 @@ set_nothrow_function_flags (void)
       {
         TREE_NOTHROW (current_function_decl) = 0;
 
-       if (GET_CODE (insn) != CALL_INSN || !SIBLING_CALL_P (insn))
+       if (!CALL_P (insn) || !SIBLING_CALL_P (insn))
          {
            cfun->all_throwers_are_sibcalls = 0;
            return;
@@ -2896,7 +2886,7 @@ set_nothrow_function_flags (void)
       {
         TREE_NOTHROW (current_function_decl) = 0;
 
-       if (GET_CODE (insn) != CALL_INSN || !SIBLING_CALL_P (insn))
+       if (!CALL_P (insn) || !SIBLING_CALL_P (insn))
          {
            cfun->all_throwers_are_sibcalls = 0;
            return;
@@ -3259,7 +3249,7 @@ collect_one_action_chain (htab_t ar_hash, struct eh_region *region)
       return collect_one_action_chain (ar_hash, region->outer);
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -3316,14 +3306,14 @@ convert_to_eh_region_ranges (void)
        rtx this_landing_pad;
 
        insn = iter;
-       if (GET_CODE (insn) == INSN
+       if (NONJUMP_INSN_P (insn)
            && GET_CODE (PATTERN (insn)) == SEQUENCE)
          insn = XVECEXP (PATTERN (insn), 0, 0);
 
        note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
        if (!note)
          {
-           if (! (GET_CODE (insn) == CALL_INSN
+           if (! (CALL_P (insn)
                   || (flag_non_call_exceptions
                       && may_trap_p (PATTERN (insn)))))
              continue;
@@ -3598,7 +3588,8 @@ output_function_exception_table (void)
   if (! cfun->uses_eh_lsda)
     return;
 
-#ifdef IA64_UNWIND_INFO
+#ifdef TARGET_UNWIND_INFO
+  /* TODO: Move this into target file.  */
   fputs ("\t.personality\t", asm_out_file);
   output_addr_const (asm_out_file, eh_personality_libfunc);
   fputs ("\n\t.handlerdata\n", asm_out_file);
@@ -3762,8 +3753,8 @@ output_function_exception_table (void)
                    cgraph_varpool_mark_needed_node (node);
                }
            }
-         else if (TREE_CODE (type) != INTEGER_CST)
-           abort ();
+         else
+           gcc_assert (TREE_CODE (type) == INTEGER_CST);
        }
 
       if (tt_format == DW_EH_PE_absptr || tt_format == DW_EH_PE_aligned)