]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* targhooks.h (struct gcc_target): New member unwind_word_mode.
authoruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Jun 2008 20:49:12 +0000 (20:49 +0000)
committeruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Jun 2008 20:49:12 +0000 (20:49 +0000)
(default_unwind_word_mode): Add prototype.
* targhooks.c (default_unwind_word_mode): New function.
(default_eh_return_filter_mode): Return targetm.unwind_word_mode ()
instead of word_mode.
* target-def.h (TARGET_UNWIND_WORD_MODE): New macro.
(TARGET_INITIALIZER): Use it.

* c-common.c (handle_mode_attribute): Support "unwind_word"
mode attribute.
* unwind-generic.h (_Unwind_Word, _Unwind_Sword): Use it.

* except.c (init_eh): Use targetm.unwind_word_mode () instead of
word_mode to access SjLj_Function_Context member "data".
(sjlj_emit_dispatch_table): Likewise.  Also, perform type
conversion from targetm.eh_return_filter_mode () to
targetm.unwind_word_mode () if they differ.

* builtin-types.def (BT_UNWINDWORD): New primitive type.
(BT_FN_UNWINDWORD_PTR): New function type.
(BT_FN_WORD_PTR): Remove.
* builtins.def (BUILT_IN_EXTEND_POINTER): Use BT_FN_UNWINDWORD_PTR.
* except.c (expand_builtin_extend_pointer): Convert pointer to
targetm.unwind_word_mode () instead of word_mode.

* config/spu/spu-protos.h (spu_eh_return_filter_mode): Remove.
* config/spu/spu.c (spu_eh_return_filter_mode): Remove.
(spu_unwind_word_mode): New function.
(TARGET_EH_RETURN_FILTER_MODE): Do not define.
(TARGET_UNWIND_WORD_MODE): Define.
* config/spu/t-spu-elf (TARGET_LIBGCC2_CFLAGS): Remove -D__word__=SI.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@136912 138bc75d-0d04-0410-961f-82ee72b054a4

13 files changed:
gcc/ChangeLog
gcc/builtin-types.def
gcc/builtins.def
gcc/c-common.c
gcc/config/spu/spu-protos.h
gcc/config/spu/spu.c
gcc/config/spu/t-spu-elf
gcc/except.c
gcc/target-def.h
gcc/target.h
gcc/targhooks.c
gcc/targhooks.h
gcc/unwind-generic.h

index 60d2007391870a4be892f21e3c440595f28f4249..a4a237a31a5755dddc004da4535f827e64aa7498 100644 (file)
@@ -1,3 +1,37 @@
+2008-06-18  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       * targhooks.h (struct gcc_target): New member unwind_word_mode.
+       (default_unwind_word_mode): Add prototype.
+       * targhooks.c (default_unwind_word_mode): New function.
+       (default_eh_return_filter_mode): Return targetm.unwind_word_mode ()
+       instead of word_mode.
+       * target-def.h (TARGET_UNWIND_WORD_MODE): New macro.
+       (TARGET_INITIALIZER): Use it.
+
+       * c-common.c (handle_mode_attribute): Support "unwind_word"
+       mode attribute.
+       * unwind-generic.h (_Unwind_Word, _Unwind_Sword): Use it.
+
+       * except.c (init_eh): Use targetm.unwind_word_mode () instead of
+       word_mode to access SjLj_Function_Context member "data".
+       (sjlj_emit_dispatch_table): Likewise.  Also, perform type
+       conversion from targetm.eh_return_filter_mode () to
+       targetm.unwind_word_mode () if they differ.
+
+       * builtin-types.def (BT_UNWINDWORD): New primitive type.
+       (BT_FN_UNWINDWORD_PTR): New function type.
+       (BT_FN_WORD_PTR): Remove.
+       * builtins.def (BUILT_IN_EXTEND_POINTER): Use BT_FN_UNWINDWORD_PTR.
+       * except.c (expand_builtin_extend_pointer): Convert pointer to
+       targetm.unwind_word_mode () instead of word_mode.
+
+       * config/spu/spu-protos.h (spu_eh_return_filter_mode): Remove.
+       * config/spu/spu.c (spu_eh_return_filter_mode): Remove.
+       (spu_unwind_word_mode): New function.
+       (TARGET_EH_RETURN_FILTER_MODE): Do not define.
+       (TARGET_UNWIND_WORD_MODE): Define.
+       * config/spu/t-spu-elf (TARGET_LIBGCC2_CFLAGS): Remove -D__word__=SI.
+
 2008-06-18  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * config/spu/spu.c (reg_align): Remove.
index 7d25e5aad6da83e5ad86eb0ef6e6335981614fd6..4676dd7641b282c04de717f2438783abd6e64b27 100644 (file)
@@ -77,6 +77,8 @@ DEF_PRIMITIVE_TYPE (BT_UINTMAX, uintmax_type_node)
 DEF_PRIMITIVE_TYPE (BT_UINT32, uint32_type_node)
 DEF_PRIMITIVE_TYPE (BT_UINT64, uint64_type_node)
 DEF_PRIMITIVE_TYPE (BT_WORD, (*lang_hooks.types.type_for_mode) (word_mode, 1))
+DEF_PRIMITIVE_TYPE (BT_UNWINDWORD, (*lang_hooks.types.type_for_mode)
+                                   (targetm.unwind_word_mode (), 1))
 DEF_PRIMITIVE_TYPE (BT_FLOAT, float_type_node)
 DEF_PRIMITIVE_TYPE (BT_DOUBLE, double_type_node)
 DEF_PRIMITIVE_TYPE (BT_LONGDOUBLE, long_double_type_node)
@@ -203,7 +205,7 @@ DEF_FUNCTION_TYPE_1 (BT_FN_DFLOAT64_CONST_STRING, BT_DFLOAT64, BT_CONST_STRING)
 DEF_FUNCTION_TYPE_1 (BT_FN_DFLOAT128_CONST_STRING,
                     BT_DFLOAT128, BT_CONST_STRING)
 DEF_FUNCTION_TYPE_1 (BT_FN_STRING_CONST_STRING, BT_STRING, BT_CONST_STRING)
-DEF_FUNCTION_TYPE_1 (BT_FN_WORD_PTR, BT_WORD, BT_PTR)
+DEF_FUNCTION_TYPE_1 (BT_FN_UNWINDWORD_PTR, BT_UNWINDWORD, BT_PTR)
 DEF_FUNCTION_TYPE_1 (BT_FN_INT_WINT, BT_INT, BT_WINT)
 DEF_FUNCTION_TYPE_1 (BT_FN_WINT_WINT, BT_WINT, BT_WINT)
 DEF_FUNCTION_TYPE_1 (BT_FN_DFLOAT32_DFLOAT32, BT_DFLOAT32, BT_DFLOAT32)
index 310e5f456a798a086cfb29e11cd341432c065f67..009c35f8934dceed9c7e59b5d5cd10c394d96962 100644 (file)
@@ -635,7 +635,7 @@ DEF_EXT_LIB_BUILTIN        (BUILT_IN_EXECVP, "execvp", BT_FN_INT_CONST_STRING_PT
 DEF_EXT_LIB_BUILTIN        (BUILT_IN_EXECVE, "execve", BT_FN_INT_CONST_STRING_PTR_CONST_STRING_PTR_CONST_STRING, ATTR_NOTHROW_LIST)
 DEF_LIB_BUILTIN        (BUILT_IN_EXIT, "exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_EXPECT, "expect", BT_FN_LONG_LONG_LONG, ATTR_CONST_NOTHROW_LIST)
-DEF_GCC_BUILTIN        (BUILT_IN_EXTEND_POINTER, "extend_pointer", BT_FN_WORD_PTR, ATTR_CONST_NOTHROW_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_EXTEND_POINTER, "extend_pointer", BT_FN_UNWINDWORD_PTR, ATTR_CONST_NOTHROW_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_EXTRACT_RETURN_ADDR, "extract_return_addr", BT_FN_PTR_PTR, ATTR_NULL)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_FFS, "ffs", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_FFSIMAX, "ffsimax", BT_FN_INT_INTMAX, ATTR_CONST_NOTHROW_LIST)
index b783c5340123a9d65a43b2b5a4d1c4940b253422..ca051c888767dca971fa58a7bf69d5772737e2c9 100644 (file)
@@ -5292,6 +5292,8 @@ handle_mode_attribute (tree *node, tree name, tree args,
        mode = targetm.libgcc_cmp_return_mode ();
       else if (!strcmp (p, "libgcc_shift_count"))
        mode = targetm.libgcc_shift_count_mode ();
+      else if (!strcmp (p, "unwind_word"))
+       mode = targetm.unwind_word_mode ();
       else
        for (j = 0; j < NUM_MACHINE_MODES; j++)
          if (!strcmp (p, GET_MODE_NAME (j)))
index e2c339bf1c5bffdb4b98d4ec3635f044c565e69d..a6b465ecff753b2eb439a6bd24600e5908fb9f4c 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "rtl.h"
 
-extern enum machine_mode spu_eh_return_filter_mode (void);
 extern void spu_cpu_cpp_builtins (struct cpp_reader * pfile);
 extern void builtin_define_std (const char *);
 extern void spu_optimization_options (int level, int size);
@@ -76,7 +75,6 @@ extern rtx gen_cpat_const (rtx * ops);
 extern void constant_to_array (enum machine_mode mode, rtx x,
                               unsigned char *arr);
 extern rtx array_to_constant (enum machine_mode mode, unsigned char *arr);
-extern enum machine_mode spu_eh_return_filter_mode (void);
 extern void spu_allocate_stack (rtx op0, rtx op1);
 extern void spu_restore_stack_nonlocal (rtx op0, rtx op1);
 extern void spu_restore_stack_block (rtx op0, rtx op1);
index 4347d59d810f8f680e2714b0c3abcd2d814e9499..4dd3d7cc0fe5b29e279ba0835b5a1e987ce6797e 100644 (file)
@@ -176,6 +176,8 @@ static int cpat_info(unsigned char *arr, int size, int *prun, int *pstart);
 static enum immediate_class classify_immediate (rtx op,
                                                enum machine_mode mode);
 
+static enum machine_mode spu_unwind_word_mode (void);
+
 static enum machine_mode
 spu_libgcc_cmp_return_mode (void);
 
@@ -193,8 +195,8 @@ tree spu_builtin_types[SPU_BTI_MAX];
 #undef TARGET_EXPAND_BUILTIN
 #define TARGET_EXPAND_BUILTIN spu_expand_builtin
 
-#undef TARGET_EH_RETURN_FILTER_MODE
-#define TARGET_EH_RETURN_FILTER_MODE spu_eh_return_filter_mode
+#undef TARGET_UNWIND_WORD_MODE
+#define TARGET_UNWIND_WORD_MODE spu_unwind_word_mode
 
 /* The .8byte directive doesn't seem to work well for a 32 bit
    architecture. */
@@ -4304,12 +4306,10 @@ spu_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total)
   return true;
 }
 
-enum machine_mode
-spu_eh_return_filter_mode (void)
+static enum machine_mode
+spu_unwind_word_mode (void)
 {
-  /* We would like this to be SImode, but sjlj exceptions seems to work
-     only with word_mode. */
-  return TImode;
+  return SImode;
 }
 
 /* Decide whether we can make a sibling call to a function.  DECL is the
index ea9825ac4971ebe9c354e5d3e205ab4471bb79da..0a3947d90175410ff499e7245e455e75924243ef 100644 (file)
@@ -19,9 +19,7 @@
 LIBGCC1 =
 CROSS_LIBGCC1 =
 
-# On SPU __word__ is TImode which is too inefficient and incomplete for
-# implementing libgcc routines.
-TARGET_LIBGCC2_CFLAGS = -fPIC -D__word__=SI -mwarn-reloc -D__IN_LIBGCC2
+TARGET_LIBGCC2_CFLAGS = -fPIC -mwarn-reloc -D__IN_LIBGCC2
 
 LIB2FUNCS_STATIC_EXTRA = $(srcdir)/config/spu/float_unssidf.c \
                         $(srcdir)/config/spu/float_unsdidf.c \
index 8ebfd7fa1db60c1ba3f28d6b7c127ab7ac837826..e6a16507cdb5929178d79bafbed5c62ed9f34c89 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;
@@ -1932,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;
@@ -1954,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);
@@ -1965,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.  */
@@ -3002,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
index 69b6169bf47b25a16e97772aa25abac927576752..2692e94aabc970afab2979435874a76806151542 100644 (file)
 #define TARGET_LIBGCC_CMP_RETURN_MODE  default_libgcc_cmp_return_mode
 #define TARGET_LIBGCC_SHIFT_COUNT_MODE default_libgcc_shift_count_mode
 
+/* In unwind-generic.h.  */
+#define TARGET_UNWIND_WORD_MODE default_unwind_word_mode
+
 /* In tree.c.  */
 #define TARGET_MERGE_DECL_ATTRIBUTES merge_decl_attributes
 #define TARGET_MERGE_TYPE_ATTRIBUTES merge_type_attributes
   TARGET_EH_RETURN_FILTER_MODE,                        \
   TARGET_LIBGCC_CMP_RETURN_MODE,                \
   TARGET_LIBGCC_SHIFT_COUNT_MODE,               \
+  TARGET_UNWIND_WORD_MODE,                     \
   TARGET_MERGE_DECL_ATTRIBUTES,                        \
   TARGET_MERGE_TYPE_ATTRIBUTES,                        \
   TARGET_ATTRIBUTE_TABLE,                      \
index 9b87dc5c3096d47c6e15e0cb3f55dd9d5ac97883..012d1c0099ba87948af63978fc0ce1f8c98d59b6 100644 (file)
@@ -463,6 +463,9 @@ struct gcc_target
   /* Return machine mode for libgcc expanded shift instructions.  */
   enum machine_mode (* libgcc_shift_count_mode) (void);
 
+  /* Return machine mode to be used for _Unwind_Word type.  */
+  enum machine_mode (* unwind_word_mode) (void);
+
   /* Given two decls, merge their attributes and return the result.  */
   tree (* merge_decl_attributes) (tree, tree);
 
index d719f5f219575bf3fffe359529e946e3f317b82a..7e931c5ed9d353456dfd36c7e282cd453495c982 100644 (file)
@@ -152,7 +152,7 @@ default_pretend_outgoing_varargs_named (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
 enum machine_mode
 default_eh_return_filter_mode (void)
 {
-  return word_mode;
+  return targetm.unwind_word_mode ();
 }
 
 enum machine_mode
@@ -167,6 +167,12 @@ default_libgcc_shift_count_mode (void)
   return word_mode;
 }
 
+enum machine_mode
+default_unwind_word_mode (void)
+{
+  return word_mode;
+}
+
 /* The default implementation of TARGET_SHIFT_TRUNCATION_MASK.  */
 
 unsigned HOST_WIDE_INT
index c94dd069f5e154f0727401586aa18966718f5cd7..5aebc7e667b2baace84e9883d82d7ce32a859244 100644 (file)
@@ -34,6 +34,7 @@ extern bool default_pretend_outgoing_varargs_named (CUMULATIVE_ARGS *);
 extern enum machine_mode default_eh_return_filter_mode (void);
 extern enum machine_mode default_libgcc_cmp_return_mode (void);
 extern enum machine_mode default_libgcc_shift_count_mode (void);
+extern enum machine_mode default_unwind_word_mode (void);
 extern unsigned HOST_WIDE_INT default_shift_truncation_mask
   (enum machine_mode);
 extern unsigned int default_min_divisions_for_recip_mul (enum machine_mode);
index aca6639dc887754e26f8d88251ddd82075e9557d..5e0f608d8eaa7b78525de2446c01d9a6d0292e6e 100644 (file)
@@ -43,8 +43,8 @@ extern "C" {
 
 /* @@@ The IA-64 ABI uses uint64 throughout.  Most places this is
    inefficient for 32-bit and smaller machines.  */
-typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
-typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
+typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
+typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
 #if defined(__ia64__) && defined(__hpux__)
 typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
 #else