Patchwork [rx] two patches: builtin-decl and target-align-max

login
register
mail settings
Submitter DJ Delorie
Date Dec. 3, 2010, 2:21 a.m.
Message ID <201012030221.oB32LEac021957@greed.delorie.com>
Download mbox | patch
Permalink /patch/74084/
State New
Headers show

Comments

DJ Delorie - Dec. 3, 2010, 2:21 a.m.
This includes a repeat (ping) of:
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02557.html

And adds target-specific support for the ALIGN_MAX hooks I converted a
short while back.  These boost coremark by 1% although it's still
slower than the 4.5 branch with similar patches.

Patch

Index: rx.h
===================================================================
--- rx.h	(revision 167405)
+++ rx.h	(working copy)
@@ -413,12 +413,18 @@  typedef unsigned int CUMULATIVE_ARGS;
 #define ASM_APP_ON		""
 #define ASM_APP_OFF 		""
 #define LOCAL_LABEL_PREFIX	"L"
 #undef  USER_LABEL_PREFIX
 #define USER_LABEL_PREFIX	"_"
 
+
+#define JUMP_ALIGN(x)				rx_align_for_label (x)
+#define LABEL_ALIGN_AFTER_BARRIER(x)		rx_align_for_label (x)
+#define LOOP_ALIGN(x)				rx_align_for_label (x)
+#define LABEL_ALIGN(x)				rx_align_for_label (x)
+
 #define ASM_OUTPUT_ALIGN(STREAM, LOG)		\
   do						\
     {						\
       if ((LOG) == 0)				\
         break;					\
       if (TARGET_AS100_SYNTAX)			\
@@ -430,12 +436,29 @@  typedef unsigned int CUMULATIVE_ARGS;
 	}					\
       else					\
 	fprintf (STREAM, "\t.balign %d\n", 1 << (LOG));	\
     }						\
   while (0)
 
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(STREAM, LOG, MAX_SKIP)	\
+  do						\
+    {						\
+      if ((LOG) == 0 || (MAX_SKIP) == 0)	\
+        break;					\
+      if (TARGET_AS100_SYNTAX)			\
+	{					\
+	  if ((LOG) >= 2)			\
+	    fprintf (STREAM, "\t.ALIGN 4\t; %d alignment actually requested\n", 1 << (LOG)); \
+	  else					\
+	    fprintf (STREAM, "\t.ALIGN 2\n");	\
+	}					\
+      else					\
+	fprintf (STREAM, "\t.balign %d,3,%d\n", 1 << (LOG), (MAX_SKIP));	\
+    }						\
+  while (0)
+
 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
   fprintf (FILE, TARGET_AS100_SYNTAX ? "\t.LWORD L%d\n" : "\t.long .L%d\n", \
 	   VALUE)
 
 /* This is how to output an element of a case-vector that is relative.
    Note: The local label referenced by the "3b" below is emitted by
Index: rx.c
===================================================================
--- rx.c	(revision 167405)
+++ rx.c	(working copy)
@@ -1827,34 +1827,39 @@  enum rx_builtin
   RX_BUILTIN_SAT,
   RX_BUILTIN_SETPSW,
   RX_BUILTIN_WAIT,
   RX_BUILTIN_max
 };
 
+static GTY(()) tree rx_builtins[(int) RX_BUILTIN_max];
+
 static void
 rx_init_builtins (void)
 {
 #define ADD_RX_BUILTIN1(UC_NAME, LC_NAME, RET_TYPE, ARG_TYPE)		\
-  add_builtin_function ("__builtin_rx_" LC_NAME,			\
+  rx_builtins[RX_BUILTIN_##UC_NAME] =					\
+    add_builtin_function ("__builtin_rx_" LC_NAME,			\
 			build_function_type_list (RET_TYPE##_type_node, \
 						  ARG_TYPE##_type_node, \
 						  NULL_TREE),		\
 			RX_BUILTIN_##UC_NAME,				\
 			BUILT_IN_MD, NULL, NULL_TREE)
 
 #define ADD_RX_BUILTIN2(UC_NAME, LC_NAME, RET_TYPE, ARG_TYPE1, ARG_TYPE2) \
-  add_builtin_function ("__builtin_rx_" LC_NAME,			\
+  rx_builtins[RX_BUILTIN_##UC_NAME] =					\
+    add_builtin_function ("__builtin_rx_" LC_NAME,			\
 			build_function_type_list (RET_TYPE##_type_node, \
 						  ARG_TYPE1##_type_node,\
 						  ARG_TYPE2##_type_node,\
 						  NULL_TREE),		\
 			RX_BUILTIN_##UC_NAME,				\
 			BUILT_IN_MD, NULL, NULL_TREE)
 
 #define ADD_RX_BUILTIN3(UC_NAME,LC_NAME,RET_TYPE,ARG_TYPE1,ARG_TYPE2,ARG_TYPE3) \
-  add_builtin_function ("__builtin_rx_" LC_NAME,			\
+  rx_builtins[RX_BUILTIN_##UC_NAME] =					\
+    add_builtin_function ("__builtin_rx_" LC_NAME,			\
 			build_function_type_list (RET_TYPE##_type_node, \
 						  ARG_TYPE1##_type_node,\
 						  ARG_TYPE2##_type_node,\
 						  ARG_TYPE3##_type_node,\
 						  NULL_TREE),		\
 			RX_BUILTIN_##UC_NAME,				\
@@ -1880,12 +1885,23 @@  rx_init_builtins (void)
   ADD_RX_BUILTIN1 (ROUND,   "round",   intSI, float);
   ADD_RX_BUILTIN1 (REVW,    "revw",    intSI, intSI);
   ADD_RX_BUILTIN1 (SAT,     "sat",     intSI, intSI);
   ADD_RX_BUILTIN1 (WAIT,    "wait",    void,  void);
 }
 
+/* Return the RX builtin for CODE.  */
+
+static tree
+rx_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
+{
+  if (code >= RX_BUILTIN_max)
+    return error_mark_node;
+
+  return rx_builtins[code];
+}
+
 static rtx
 rx_expand_void_builtin_1_arg (rtx arg, rtx (* gen_func)(rtx), bool reg)
 {
   if (reg && ! REG_P (arg))
     arg = force_reg (SImode, arg);
 
@@ -2754,12 +2770,53 @@  rx_compare_redundant (rtx cmp)
 static int
 rx_memory_move_cost (enum machine_mode mode, reg_class_t regclass, bool in)
 {
   return 2 + memory_move_secondary_cost (mode, regclass, in);
 }
 
+int
+rx_align_for_label (rtx lab)
+{
+  return 3;
+}
+
+int
+rx_max_skip_for_label (rtx lab)
+{
+  int opsize;
+  rtx op;
+
+  op = lab;
+  do {
+    op = next_nonnote_insn (op);
+  } while (op && (LABEL_P (op)
+		  || (INSN_P (op) && GET_CODE (PATTERN (op)) == USE)));
+  if (!op)
+    return 0;
+
+  opsize = get_attr_length (op);
+  if (opsize >= 0 && opsize < 8)
+    return opsize - 1;
+  return 0;
+}
+
+#if 1
+#undef  TARGET_ASM_JUMP_ALIGN_MAX_SKIP
+#define TARGET_ASM_JUMP_ALIGN_MAX_SKIP rx_max_skip_for_label
+
+#undef  TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP
+#define TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP rx_max_skip_for_label
+
+#undef  TARGET_ASM_LOOP_ALIGN_MAX_SKIP
+#define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rx_max_skip_for_label
+
+#undef  TARGET_ASM_LABEL_ALIGN_MAX_SKIP
+#define TARGET_ASM_LABEL_ALIGN_MAX_SKIP rx_max_skip_for_label
+#endif
+
+
 #undef  TARGET_FUNCTION_VALUE
 #define TARGET_FUNCTION_VALUE		rx_function_value
 
 #undef  TARGET_RETURN_IN_MSB
 #define TARGET_RETURN_IN_MSB		rx_return_in_msb
 
@@ -2778,12 +2835,15 @@  rx_memory_move_cost (enum machine_mode m
 #undef	TARGET_ASM_SELECT_SECTION
 #define	TARGET_ASM_SELECT_SECTION	rx_select_section
 
 #undef  TARGET_INIT_BUILTINS
 #define TARGET_INIT_BUILTINS		rx_init_builtins
 
+#undef  TARGET_BUILTIN_DECL
+#define TARGET_BUILTIN_DECL		rx_builtin_decl
+
 #undef  TARGET_EXPAND_BUILTIN
 #define TARGET_EXPAND_BUILTIN		rx_expand_builtin
 
 #undef  TARGET_ASM_CONSTRUCTOR
 #define TARGET_ASM_CONSTRUCTOR		rx_elf_asm_constructor
 
@@ -2882,7 +2942,7 @@  rx_memory_move_cost (enum machine_mode m
 
 #undef  TARGET_EXCEPT_UNWIND_INFO
 #define TARGET_EXCEPT_UNWIND_INFO		sjlj_except_unwind_info
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 
-/* #include "gt-rx.h" */
+#include "gt-rx.h"