OSDN Git Service

* gcc.dg/vect/vect.exp: Run tests with -funroll-loops for SPU in case
[pf3gnuchains/gcc-fork.git] / gcc / except.c
index b1f2332..1d9a736 100644 (file)
@@ -338,7 +338,8 @@ init_eh (void)
       DECL_FIELD_CONTEXT (f_cs) = sjlj_fc_type_node;
 
       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 = build_array_type (lang_hooks.types.type_for_mode
+                               (targetm.unwind_word_mode (), 1),
                              tmp);
       f_data = build_decl (FIELD_DECL, get_identifier ("__data"), tmp);
       DECL_FIELD_CONTEXT (f_data) = sjlj_fc_type_node;
@@ -408,7 +409,7 @@ init_eh (void)
 void
 init_eh_for_function (void)
 {
-  cfun->eh = ggc_alloc_cleared (sizeof (struct eh_status));
+  cfun->eh = GGC_CNEW (struct eh_status);
 }
 \f
 /* Routines to generate the exception tree somewhat directly.
@@ -425,7 +426,7 @@ gen_eh_region (enum eh_region_type type, struct eh_region *outer)
 #endif
 
   /* Insert a new blank region as a leaf in the tree.  */
-  new = ggc_alloc_cleared (sizeof (*new));
+  new = GGC_CNEW (struct eh_region);
   new->type = type;
   new->outer = outer;
   if (outer)
@@ -540,6 +541,7 @@ expand_resx_expr (tree exp)
                                     cfun->eh->region_array, region_nr);
 
   gcc_assert (!reg->resume);
+  do_pending_stack_adjust ();
   reg->resume = emit_jump_insn (gen_rtx_RESX (VOIDmode, region_nr));
   emit_barrier ();
 }
@@ -630,8 +632,8 @@ remove_unreachable_regions (rtx insns)
   struct eh_region *r;
   rtx insn;
 
-  uid_region_num = xcalloc (get_max_uid (), sizeof(int));
-  reachable = xcalloc (cfun->eh->last_region_number + 1, sizeof(bool));
+  uid_region_num = XCNEWVEC (int, get_max_uid ());
+  reachable = XCNEWVEC (bool, cfun->eh->last_region_number + 1);
 
   for (i = cfun->eh->last_region_number; i > 0; --i)
     {
@@ -734,7 +736,7 @@ add_ehl_entry (rtx label, struct eh_region *region)
 
   LABEL_PRESERVE_P (label) = 1;
 
-  entry = ggc_alloc (sizeof (*entry));
+  entry = GGC_NEW (struct ehl_map_entry);
   entry->label = label;
   entry->region = region;
 
@@ -845,7 +847,7 @@ duplicate_eh_regions_1 (eh_region old, eh_region outer, int eh_offset)
 {
   eh_region ret, n;
 
-  ret = n = ggc_alloc (sizeof (struct eh_region));
+  ret = n = GGC_NEW (struct eh_region);
 
   *n = *old;
   n->outer = outer;
@@ -1691,7 +1693,7 @@ sjlj_assign_call_site_values (rtx dispatch_label, struct sjlj_lp_info *lp_info)
        r->landing_pad = dispatch_label;
        lp_info[i].action_index = collect_one_action_chain (ar_hash, r);
        if (lp_info[i].action_index != -1)
-         cfun->uses_eh_lsda = 1;
+         crtl->uses_eh_lsda = 1;
       }
 
   htab_delete (ar_hash);
@@ -1817,7 +1819,7 @@ sjlj_emit_function_enter (rtx dispatch_label)
   emit_move_insn (mem, eh_personality_libfunc);
 
   mem = adjust_address (fc, Pmode, sjlj_fc_lsda_ofs);
-  if (cfun->uses_eh_lsda)
+  if (crtl->uses_eh_lsda)
     {
       char buf[20];
       rtx sym;
@@ -1931,6 +1933,8 @@ sjlj_emit_function_exit (void)
 static void
 sjlj_emit_dispatch_table (rtx dispatch_label, struct sjlj_lp_info *lp_info)
 {
+  enum machine_mode unwind_word_mode = targetm.unwind_word_mode ();
+  enum machine_mode filter_mode = targetm.eh_return_filter_mode ();
   int i, first_reachable;
   rtx mem, dispatch, seq, fc;
   rtx before;
@@ -1953,8 +1957,8 @@ sjlj_emit_dispatch_table (rtx dispatch_label, struct sjlj_lp_info *lp_info)
                        sjlj_fc_call_site_ofs);
   dispatch = copy_to_reg (mem);
 
-  mem = adjust_address (fc, word_mode, sjlj_fc_data_ofs);
-  if (word_mode != ptr_mode)
+  mem = adjust_address (fc, unwind_word_mode, sjlj_fc_data_ofs);
+  if (unwind_word_mode != ptr_mode)
     {
 #ifdef POINTERS_EXTEND_UNSIGNED
       mem = convert_memory_address (ptr_mode, mem);
@@ -1964,7 +1968,10 @@ sjlj_emit_dispatch_table (rtx dispatch_label, struct sjlj_lp_info *lp_info)
     }
   emit_move_insn (crtl->eh.exc_ptr, mem);
 
-  mem = adjust_address (fc, word_mode, sjlj_fc_data_ofs + UNITS_PER_WORD);
+  mem = adjust_address (fc, unwind_word_mode,
+                       sjlj_fc_data_ofs + GET_MODE_SIZE (unwind_word_mode));
+  if (unwind_word_mode != filter_mode)
+    mem = convert_to_mode (filter_mode, mem, 0);
   emit_move_insn (crtl->eh.filter, mem);
 
   /* Jump to one of the directly reachable regions.  */
@@ -2580,7 +2587,7 @@ foreach_reachable_handler (int region_number, bool is_resx,
 static void
 arh_to_landing_pad (struct eh_region *region, void *data)
 {
-  rtx *p_handlers = data;
+  rtx *p_handlers = (rtx *) data;
   if (! *p_handlers)
     *p_handlers = alloc_INSN_LIST (region->landing_pad, NULL_RTX);
 }
@@ -2588,7 +2595,7 @@ arh_to_landing_pad (struct eh_region *region, void *data)
 static void
 arh_to_label (struct eh_region *region, void *data)
 {
-  rtx *p_handlers = data;
+  rtx *p_handlers = (rtx *) data;
   *p_handlers = alloc_INSN_LIST (region->label, *p_handlers);
 }
 
@@ -2746,7 +2753,7 @@ can_throw_external (const_rtx insn)
   return can_throw_external_1 (INTVAL (XEXP (note, 0)), false);
 }
 
-/* Set TREE_NOTHROW and cfun->all_throwers_are_sibcalls.  */
+/* Set TREE_NOTHROW and crtl->all_throwers_are_sibcalls.  */
 
 unsigned int
 set_nothrow_function_flags (void)
@@ -2761,13 +2768,13 @@ set_nothrow_function_flags (void)
 
   TREE_NOTHROW (current_function_decl) = 1;
 
-  /* Assume cfun->all_throwers_are_sibcalls until we encounter
+  /* Assume crtl->all_throwers_are_sibcalls until we encounter
      something that can throw an exception.  We specifically exempt
      CALL_INSNs that are SIBLING_CALL_P, as these are really jumps,
      and can't throw.  Most CALL_INSNs are not SIBLING_CALL_P, so this
      is optimistic.  */
 
-  cfun->all_throwers_are_sibcalls = 1;
+  crtl->all_throwers_are_sibcalls = 1;
 
   if (! flag_exceptions)
     return 0;
@@ -2779,12 +2786,12 @@ set_nothrow_function_flags (void)
 
        if (!CALL_P (insn) || !SIBLING_CALL_P (insn))
          {
-           cfun->all_throwers_are_sibcalls = 0;
+           crtl->all_throwers_are_sibcalls = 0;
            return 0;
          }
       }
 
-  for (insn = current_function_epilogue_delay_list; insn;
+  for (insn = crtl->epilogue_delay_list; insn;
        insn = XEXP (insn, 1))
     if (can_throw_external (insn))
       {
@@ -2792,7 +2799,7 @@ set_nothrow_function_flags (void)
 
        if (!CALL_P (insn) || !SIBLING_CALL_P (insn))
          {
-           cfun->all_throwers_are_sibcalls = 0;
+           crtl->all_throwers_are_sibcalls = 0;
            return 0;
          }
       }
@@ -2829,7 +2836,7 @@ expand_builtin_unwind_init (void)
 {
   /* Set this so all the registers get saved in our frame; we need to be
      able to copy the saved values for any registers from frames we unwind.  */
-  current_function_saves_all_registers = 1;
+  crtl->saves_all_registers = 1;
 
 #ifdef SETUP_FRAME_ADDRESSES
   SETUP_FRAME_ADDRESSES ();
@@ -2952,7 +2959,7 @@ expand_eh_return (void)
   if (! crtl->eh.ehr_label)
     return;
 
-  current_function_calls_eh_return = 1;
+  crtl->calls_eh_return = 1;
 
 #ifdef EH_RETURN_STACKADJ_RTX
   emit_move_insn (EH_RETURN_STACKADJ_RTX, const0_rtx);
@@ -3001,7 +3008,7 @@ expand_builtin_extend_pointer (tree addr_tree)
   extend = 1;
 #endif
 
-  return convert_modes (word_mode, ptr_mode, addr, extend);
+  return convert_modes (targetm.unwind_word_mode (), ptr_mode, addr, extend);
 }
 \f
 /* In the following functions, we represent entries in the action table
@@ -3048,7 +3055,7 @@ add_action_record (htab_t ar_hash, int filter, int next)
 
   if ((new = *slot) == NULL)
     {
-      new = xmalloc (sizeof (*new));
+      new = XNEW (struct action_record);
       new->offset = VARRAY_ACTIVE_SIZE (crtl->eh.action_record_data) + 1;
       new->filter = filter;
       new->next = next;
@@ -3184,7 +3191,7 @@ add_call_site (rtx landing_pad, int action)
 {
   call_site_record record;
   
-  record = ggc_alloc (sizeof (struct call_site_record));
+  record = GGC_NEW (struct call_site_record);
   record->landing_pad = landing_pad;
   record->action = action;
 
@@ -3248,7 +3255,7 @@ convert_to_eh_region_ranges (void)
        /* Existence of catch handlers, or must-not-throw regions
           implies that an lsda is needed (even if empty).  */
        if (this_action != -1)
-         cfun->uses_eh_lsda = 1;
+         crtl->uses_eh_lsda = 1;
 
        /* Delay creation of region notes for no-action regions
           until we're sure that an lsda will be required.  */
@@ -3379,13 +3386,13 @@ push_sleb128 (varray_type *data_area, int value)
 static int
 dw2_size_of_call_site_table (void)
 {
-  int n = cfun->eh->call_site_data_used;
+  int n = VEC_length (call_site_record, crtl->eh.call_site_record);
   int size = n * (4 + 4 + 4);
   int i;
 
   for (i = 0; i < n; ++i)
     {
-      struct call_site_record *cs = &cfun->eh->call_site_data[i];
+      struct call_site_record *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
       size += size_of_uleb128 (cs->action);
     }
 
@@ -3395,13 +3402,13 @@ dw2_size_of_call_site_table (void)
 static int
 sjlj_size_of_call_site_table (void)
 {
-  int n = cfun->eh->call_site_data_used;
+  int n = VEC_length (call_site_record, crtl->eh.call_site_record);
   int size = 0;
   int i;
 
   for (i = 0; i < n; ++i)
     {
-      struct call_site_record *cs = &cfun->eh->call_site_data[i];
+      struct call_site_record *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
       size += size_of_uleb128 (INTVAL (cs->landing_pad));
       size += size_of_uleb128 (cs->action);
     }
@@ -3515,7 +3522,7 @@ switch_to_exception_section (const char * ARG_UNUSED (fnname))
 #ifdef HAVE_LD_EH_GC_SECTIONS
          if (flag_function_sections)
            {
-             char *section_name = xmalloc (strlen (fnname) + 32);
+             char *section_name = XNEWVEC (char, strlen (fnname) + 32);
              sprintf (section_name, ".gcc_except_table.%s", fnname);
              s = get_section (section_name, flags, NULL);
              free (section_name);
@@ -3599,7 +3606,7 @@ output_function_exception_table (const char * ARG_UNUSED (fnname))
   int tt_format_size = 0;
 
   /* Not all functions need anything.  */
-  if (! cfun->uses_eh_lsda)
+  if (! crtl->uses_eh_lsda)
     return;
 
   if (eh_personality_libfunc)