public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, alpha]: Hookize some more macros
@ 2015-11-12 12:20 Uros Bizjak
  0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2015-11-12 12:20 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]

2015-11-12  Uros Bizjak  <ubizjak@gmail.com>

    * config/alpha/alpha.h (FUNCTION_VALUE, LIBCALL_VALUE,
    FUNCTION_VALUE_REGNO_P): Remove.
    * config/alpha/alpha-protos.h (function_value): Remove.
    * config/alpha/alpha.c (function_value): Rename to...
    (alpha_function_value_1): ... this.  Make static.
    (alpha_function_value, alpha_libcall_value,
    alpha_function_value_regno_p): New functions.
    (TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE,
    TARGET_FUNCTION_VALUE_REGNO_P): Define.

2015-11-12  Uros Bizjak  <ubizjak@gmail.com>

    * config/alpha/alpha.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
    * config/alpha/alpha.c (alpha_memory_latency): Make static.
    (alpha_register_move_cost, alpha_memory_move_cost): New functions.
    (TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.

Bootstrapped and regression tested on alphaev68-linux-gnu, committed
to mainline SVN.

Uros.

[-- Attachment #2: a.diff.txt --]
[-- Type: text/plain, Size: 6637 bytes --]

Index: config/alpha/alpha-protos.h
===================================================================
--- config/alpha/alpha-protos.h	(revision 230213)
+++ config/alpha/alpha-protos.h	(working copy)
@@ -68,7 +68,6 @@
 extern void alpha_initialize_trampoline (rtx, rtx, rtx, int, int, int);
 
 extern rtx alpha_va_arg (tree, tree);
-extern rtx function_value (const_tree, const_tree, machine_mode);
 
 extern void alpha_start_function (FILE *, const char *, tree);
 extern void alpha_end_function (FILE *, const char *, tree);
Index: config/alpha/alpha.c
===================================================================
--- config/alpha/alpha.c	(revision 230213)
+++ config/alpha/alpha.c	(working copy)
@@ -95,7 +95,7 @@
 
 /* The number of cycles of latency we should assume on memory reads.  */
 
-int alpha_memory_latency = 3;
+static int alpha_memory_latency = 3;
 
 /* Whether the function needs the GP.  */
 
@@ -1339,6 +1339,36 @@
   return NULL_RTX;
 }
 \f
+/* Return the cost of moving between registers of various classes.  Moving
+   between FLOAT_REGS and anything else except float regs is expensive.
+   In fact, we make it quite expensive because we really don't want to
+   do these moves unless it is clearly worth it.  Optimizations may
+   reduce the impact of not being able to allocate a pseudo to a
+   hard register.  */
+
+static int
+alpha_register_move_cost (machine_mode /*mode*/,
+			  reg_class_t from, reg_class_t to)
+{
+  if ((from == FLOAT_REGS) == (to == FLOAT_REGS))
+    return 2;
+
+  if (TARGET_FIX)
+    return (from == FLOAT_REGS) ? 6 : 8;
+
+  return 4 + 2 * alpha_memory_latency;
+}
+
+/* Return the cost of moving data of MODE from a register to
+   or from memory.  On the Alpha, bump this up a bit.  */
+
+static int
+alpha_memory_move_cost (machine_mode /*mode*/, reg_class_t /*regclass*/,
+			bool /*in*/)
+{
+  return 2 * alpha_memory_latency;
+}
+
 /* Compute a (partial) cost for rtx X.  Return true if the complete
    cost has been computed, and false if subexpressions should be
    scanned.  In either case, *TOTAL contains the cost result.  */
@@ -5736,9 +5766,9 @@
    On Alpha the value is found in $0 for integer functions and
    $f0 for floating-point functions.  */
 
-rtx
-function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED,
-		machine_mode mode)
+static rtx
+alpha_function_value_1 (const_tree valtype, const_tree func ATTRIBUTE_UNUSED,
+			machine_mode mode)
 {
   unsigned int regnum, dummy ATTRIBUTE_UNUSED;
   enum mode_class mclass;
@@ -5793,6 +5823,33 @@
   return gen_rtx_REG (mode, regnum);
 }
 
+/* Implement TARGET_FUNCTION_VALUE.  */
+
+static rtx
+alpha_function_value (const_tree valtype, const_tree fn_decl_or_type,
+		      bool /*outgoing*/)
+{
+  return alpha_function_value_1 (valtype, fn_decl_or_type, VOIDmode);
+}
+
+/* Implement TARGET_LIBCALL_VALUE.  */
+
+static rtx
+alpha_libcall_value (machine_mode mode, const_rtx /*fun*/)
+{
+  return alpha_function_value_1 (NULL_TREE, NULL_TREE, mode);
+}
+
+/* Implement TARGET_FUNCTION_VALUE_REGNO_P.
+
+   On the Alpha, $0 $1 and $f0 $f1 are the only register thus used.  */
+
+static bool
+alpha_function_value_regno_p (const unsigned int regno)
+{
+  return (regno == 0 || regno == 1 || regno == 32 || regno == 33);
+}
+
 /* TCmode complex values are passed by invisible reference.  We
    should not split these values.  */
 
@@ -9908,6 +9965,10 @@
 #undef TARGET_USE_BLOCKS_FOR_CONSTANT_P
 #define TARGET_USE_BLOCKS_FOR_CONSTANT_P hook_bool_mode_const_rtx_true
 
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST alpha_register_move_cost
+#undef TARGET_MEMORY_MOVE_COST
+#define TARGET_MEMORY_MOVE_COST alpha_memory_move_cost
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS alpha_rtx_costs
 #undef TARGET_ADDRESS_COST
@@ -9920,6 +9981,13 @@
 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
 #undef TARGET_PROMOTE_PROTOTYPES
 #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_false
+
+#undef TARGET_FUNCTION_VALUE
+#define TARGET_FUNCTION_VALUE alpha_function_value
+#undef TARGET_LIBCALL_VALUE
+#define TARGET_LIBCALL_VALUE alpha_libcall_value
+#undef TARGET_FUNCTION_VALUE_REGNO_P
+#define TARGET_FUNCTION_VALUE_REGNO_P alpha_function_value_regno_p
 #undef TARGET_RETURN_IN_MEMORY
 #define TARGET_RETURN_IN_MEMORY alpha_return_in_memory
 #undef TARGET_PASS_BY_REFERENCE
Index: config/alpha/alpha.h
===================================================================
--- config/alpha/alpha.h	(revision 230213)
+++ config/alpha/alpha.h	(working copy)
@@ -537,26 +537,6 @@
   (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO)			\
    ? reg_classes_intersect_p (FLOAT_REGS, CLASS) : 0)
 
-/* Define the cost of moving between registers of various classes.  Moving
-   between FLOAT_REGS and anything else except float regs is expensive.
-   In fact, we make it quite expensive because we really don't want to
-   do these moves unless it is clearly worth it.  Optimizations may
-   reduce the impact of not being able to allocate a pseudo to a
-   hard register.  */
-
-#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2)		\
-  (((CLASS1) == FLOAT_REGS) == ((CLASS2) == FLOAT_REGS)	? 2	\
-   : TARGET_FIX ? ((CLASS1) == FLOAT_REGS ? 6 : 8)		\
-   : 4+2*alpha_memory_latency)
-
-/* A C expressions returning the cost of moving data of MODE from a register to
-   or from memory.
-
-   On the Alpha, bump this up a bit.  */
-
-extern int alpha_memory_latency;
-#define MEMORY_MOVE_COST(MODE,CLASS,IN)  (2*alpha_memory_latency)
-
 /* Provide the cost of a branch.  Exact meaning under development.  */
 #define BRANCH_COST(speed_p, predictable_p) 5
 \f
@@ -626,29 +606,6 @@
    in a register.  */
 /* #define REG_PARM_STACK_SPACE */
 
-/* Define how to find the value returned by a function.
-   VALTYPE is the data type of the value (as a tree).
-   If the precise function being called is known, FUNC is its FUNCTION_DECL;
-   otherwise, FUNC is 0.
-
-   On Alpha the value is found in $0 for integer functions and
-   $f0 for floating-point functions.  */
-
-#define FUNCTION_VALUE(VALTYPE, FUNC) \
-  function_value (VALTYPE, FUNC, VOIDmode)
-
-/* Define how to find the value returned by a library function
-   assuming the value has mode MODE.  */
-
-#define LIBCALL_VALUE(MODE) \
-  function_value (NULL, NULL, MODE)
-
-/* 1 if N is a possible register number for a function value
-   as seen by the caller.  */
-
-#define FUNCTION_VALUE_REGNO_P(N)  \
-  ((N) == 0 || (N) == 1 || (N) == 32 || (N) == 33)
-
 /* 1 if N is a possible register number for function argument passing.
    On Alpha, these are $16-$21 and $f16-$f21.  */
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-12 12:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 12:20 [PATCH, alpha]: Hookize some more macros Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).