public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [H8300] Hookize target macros
@ 2010-09-01  9:42 Naveen H. S
  2010-09-03 15:06 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen H. S @ 2010-09-01  9:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Prafulla Thakare

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

Hi,

Please find attached the patch which hookizes REGISTER_MOVE_COST,
PRINT_OPERAND, FUNCTION_VAL and related macros for the h8300 backend.
Please review the patch and let me know if there should be any 
modifications in it.

Tested with h8300-elf.  No new regressions.
	
ChangeLog
2010-09-01  Naveen H.S  <naveen.S@kpitcummins.com>

	* config/h8300/h8300.c (h8300_print_operand_address): Make static.
	Adjust comments. Declare.
	(h8300_print_operand): Likewise.
	(h8300_print_operand_punct_valid_p): Moved from h8300.h file. 
	(h8300_function_value): Likewise.
	(h8300_function_value_regno_p): Likewise.
	(h8300_register_move_cost): Likewise.
	(TARGET_PRINT_OPERAND_PUNCT_VALID_P, TARGET_PRINT_OPERAND
	TARGET_PRINT_OPERAND_ADDRESS, TARGET_REGISTER_MOVE_COST
	TARGET_FUNCTION_VALUE, TARGET_FUNCTION_VALUE_REGNO_P): Define.
	* config/h8300/h8300.h (PRINT_OPERAND_ADDRESS, PRINT_OPERAND
	PRINT_OPERAND_PUNCT_VALID_P, REGISTER_MOVE_COST, FUNCTION_VALUE
	FUNCTION_VALUE_REGNO_P): Delete.
	* config/h8300/h8300-protos.h (print_operand): Delete.
	(print_operand_address): Delete.

Thanks & Regards,
Naveen


[-- Attachment #2: targhooks-h8300.patch --]
[-- Type: application/octet-stream, Size: 10597 bytes --]

--- orig/gcc/config/h8300/h8300.c	2010-09-01 14:23:18.000000000 +0530
+++ trunk/gcc/config/h8300/h8300.c	2010-09-01 14:25:19.000000000 +0530
@@ -93,9 +93,13 @@ static unsigned int h8300_asm_insn_count
 static tree h8300_handle_fndecl_attribute (tree *, tree, tree, int, bool *);
 static tree h8300_handle_eightbit_data_attribute (tree *, tree, tree, int, bool *);
 static tree h8300_handle_tiny_data_attribute (tree *, tree, tree, int, bool *);
+static void h8300_print_operand_address (FILE *, rtx);
+static void h8300_print_operand (FILE *, rtx, int);
+static bool h8300_print_operand_punct_valid_p (unsigned char code);
 #ifndef OBJECT_FORMAT_ELF
 static void h8300_asm_named_section (const char *, unsigned int, tree);
 #endif
+static int h8300_register_move_cost (enum machine_mode, reg_class_t, reg_class_t);
 static int h8300_and_costs (rtx);
 static int h8300_shift_costs (rtx);
 static void          h8300_push_pop               (int, int, bool, bool);
@@ -113,6 +117,8 @@ static unsigned int  h8300_binary_length
 static bool          h8300_short_move_mem_p       (rtx, enum rtx_code);
 static unsigned int  h8300_move_length            (rtx *, const h8300_length_table *);
 static bool	     h8300_hard_regno_scratch_ok  (unsigned int);
+static rtx h8300_function_value (const_tree, const_tree, bool);
+static bool h8300_function_value_regno_p (const unsigned int);
 
 /* CPU_TYPE, says what cpu we're compiling for.  */
 int cpu_type;
@@ -1153,6 +1159,20 @@ function_arg (CUMULATIVE_ARGS *cum, enum
   return result;
 }
 
+/* Any SI register-to-register move may need to be reloaded,
+   so define REGISTER_MOVE_COST to be > 2 so that reload never
+   shortcuts.  */
+
+static int
+h8300_register_move_cost (enum machine_mode mode,
+                         reg_class_t from, reg_class_t to)
+{
+  if (from == MAC_REGS || to == MAC_REG)
+     return 6;
+  else
+     return 3;
+}
+
 /* Compute the cost of an and insn.  */
 
 static int
@@ -1421,8 +1441,8 @@ cond_string (enum rtx_code code)
 /* Print operand X using operand code CODE to assembly language output file
    FILE.  */
 
-void
-print_operand (FILE *file, rtx x, int code)
+static void
+h8300_print_operand (FILE *file, rtx x, int code)
 {
   /* This is used for communication between codes V,W,Z and Y.  */
   static int bitint;
@@ -1501,7 +1521,7 @@ print_operand (FILE *file, rtx x, int co
       if (GET_CODE (x) == REG)
 	fprintf (file, "%s%c", names_big[REGNO (x)], bitint > 7 ? 'h' : 'l');
       else
-	print_operand (file, x, 'R');
+	h8300_print_operand (file, x, 'R');
       bitint = -1;
       break;
     case 'Z':
@@ -1534,7 +1554,7 @@ print_operand (FILE *file, rtx x, int co
 	    fprintf (file, "%s", names_upper_extended[REGNO (x)]);
 	  break;
 	case MEM:
-	  print_operand (file, x, 0);
+	  h8300_print_operand (file, x, 0);
 	  break;
 	case CONST_INT:
 	  fprintf (file, "#%ld", ((INTVAL (x) >> 16) & 0xffff));
@@ -1564,7 +1584,7 @@ print_operand (FILE *file, rtx x, int co
 	  break;
 	case MEM:
 	  x = adjust_address (x, HImode, 2);
-	  print_operand (file, x, 0);
+	  h8300_print_operand (file, x, 0);
 	  break;
 	case CONST_INT:
 	  fprintf (file, "#%ld", INTVAL (x) & 0xffff);
@@ -1609,7 +1629,7 @@ print_operand (FILE *file, rtx x, int co
 	}
       break;
     case 'o':
-      print_operand_address (file, x);
+      h8300_print_operand_address (file, x);
       break;
     case 's':
       if (GET_CODE (x) == CONST_INT)
@@ -1726,7 +1746,7 @@ print_operand (FILE *file, rtx x, int co
 	case CONST:
 	case LABEL_REF:
 	  fprintf (file, "#");
-	  print_operand_address (file, x);
+	  h8300_print_operand_address (file, x);
 	  break;
 	case CONST_DOUBLE:
 	  {
@@ -1743,10 +1763,18 @@ print_operand (FILE *file, rtx x, int co
     }
 }
 
+/* Implements TARGET_PRINT_OPERAND_PUNCT_VALID_P.  */
+
+static bool
+h8300_print_operand_punct_valid_p (unsigned char code)
+{
+  return (code == '#');
+}
+
 /* Output assembly language output for the address ADDR to FILE.  */
 
-void
-print_operand_address (FILE *file, rtx addr)
+static void
+h8300_print_operand_address (FILE *file, rtx addr)
 {
   rtx index;
   int size;
@@ -1780,37 +1808,37 @@ print_operand_address (FILE *file, rtx a
       if (GET_CODE (index) == REG)
 	{
 	  /* reg,foo */
-	  print_operand_address (file, XEXP (addr, 1));
+	  h8300_print_operand_address (file, XEXP (addr, 1));
 	  fprintf (file, ",");
 	  switch (size)
 	    {
 	    case 0:
-	      print_operand_address (file, index);
+	      h8300_print_operand_address (file, index);
 	      break;
 
 	    case 1:
-	      print_operand (file, index, 'X');
+	      h8300_print_operand (file, index, 'X');
 	      fputs (".b", file);
 	      break;
 
 	    case 2:
-	      print_operand (file, index, 'T');
+	      h8300_print_operand (file, index, 'T');
 	      fputs (".w", file);
 	      break;
 
 	    case 4:
-	      print_operand (file, index, 'S');
+	      h8300_print_operand (file, index, 'S');
 	      fputs (".l", file);
 	      break;
 	    }
-	  /* print_operand_address (file, XEXP (addr, 0)); */
+	  /* h8300_print_operand_address (file, XEXP (addr, 0)); */
 	}
       else
 	{
 	  /* foo+k */
-	  print_operand_address (file, XEXP (addr, 0));
+	  h8300_print_operand_address (file, XEXP (addr, 0));
 	  fprintf (file, "+");
-	  print_operand_address (file, XEXP (addr, 1));
+	  h8300_print_operand_address (file, XEXP (addr, 1));
 	}
       fprintf (file, ")");
       break;
@@ -3694,7 +3722,7 @@ h8sx_classify_shift (enum machine_mode m
 /* Return the asm template for a single h8sx shift instruction.
    OPERANDS[0] and OPERANDS[1] are the destination, OPERANDS[2]
    is the source and OPERANDS[3] is the shift.  SUFFIX is the
-   size suffix ('b', 'w' or 'l') and OPTYPE is the print_operand
+   size suffix ('b', 'w' or 'l') and OPTYPE is the h8300_print_operand
    prefix for the destination operand.  */
 
 const char *
@@ -5815,6 +5843,25 @@ h8300_init_libfuncs (void)
   set_optab_libfunc (umod_optab, HImode, "__umodhi3");
 }
 
+/* Implements TARGET_FUNCTION_VALUE.
+   On the H8 the return value is in R0 register.  */
+
+static rtx
+h8300_function_value (const_tree valtype, const_tree fntype_or_decl,
+                     bool outgoing ATTRIBUTE_UNUSED)
+{
+  return gen_rtx_REG (TYPE_MODE (valtype), R0_REG);
+}
+
+/* Return true if N is a possible register number of function value.
+   On the H8, R0 is the register used.  */
+
+static bool
+h8300_function_value_regno_p (const unsigned int regno)
+{
+  return (regno == R0_REG);
+}
+
 /* Worker function for TARGET_RETURN_IN_MEMORY.  */
 
 static bool
@@ -5889,12 +5936,22 @@ h8300_trampoline_init (rtx m_tramp, tree
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END h8300_file_end
 
+#undef TARGET_PRINT_OPERAND
+#define TARGET_PRINT_OPERAND h8300_print_operand
+#undef TARGET_PRINT_OPERAND_ADDRESS
+#define TARGET_PRINT_OPERAND_ADDRESS h8300_print_operand_address
+#undef TARGET_PRINT_OPERAND_PUNCT_VALID_P
+#define TARGET_PRINT_OPERAND_PUNCT_VALID_P h8300_print_operand_punct_valid_p
+
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO h8300_encode_section_info
 
 #undef TARGET_INSERT_ATTRIBUTES
 #define TARGET_INSERT_ATTRIBUTES h8300_insert_attributes
 
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST h8300_register_move_cost
+
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS h8300_rtx_costs
 
@@ -5922,4 +5979,11 @@ h8300_trampoline_init (rtx m_tramp, tree
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT h8300_trampoline_init
 
+#undef TARGET_FUNCTION_VALUE
+#define TARGET_FUNCTION_VALUE h8300_function_value
+
+#undef TARGET_FUNCTION_VALUE_REGNO_P
+#define TARGET_FUNCTION_VALUE_REGNO_P h8300_function_value_regno_p
+
+
 struct gcc_target targetm = TARGET_INITIALIZER;
--- orig/gcc/config/h8300/h8300.h	2010-06-29 17:48:36.000000000 +0530
+++ trunk/gcc/config/h8300/h8300.h	2010-09-01 14:15:33.000000000 +0530
@@ -489,13 +489,6 @@ enum reg_class {
 #define CLASS_MAX_NREGS(CLASS, MODE)	\
   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
 
-/* Any SI register-to-register move may need to be reloaded,
-   so define REGISTER_MOVE_COST to be > 2 so that reload never
-   shortcuts.  */
-
-#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2)  \
-  (CLASS1 == MAC_REGS || CLASS2 == MAC_REGS ? 6 : 3)
-\f
 /* Stack layout; function entry, exit and calling.  */
 
 /* Define this if pushing a word on the stack
@@ -564,16 +557,6 @@ enum reg_class {
 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)		\
   ((OFFSET) = h8300_initial_elimination_offset ((FROM), (TO)))
 
-/* 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 the H8 the return value is in R0/R1.  */
-
-#define FUNCTION_VALUE(VALTYPE, FUNC) \
-  gen_rtx_REG (TYPE_MODE (VALTYPE), R0_REG)
-
 /* Define how to find the value returned by a library function
    assuming the value has mode MODE.  */
 
@@ -582,11 +565,6 @@ enum reg_class {
 #define LIBCALL_VALUE(MODE) \
   gen_rtx_REG (MODE, R0_REG)
 
-/* 1 if N is a possible register number for a function value.
-   On the H8, R0 is the only register thus used.  */
-
-#define FUNCTION_VALUE_REGNO_P(N) ((N) == R0_REG)
-
 /* Define this if PCC uses the nonreentrant convention for returning
    structure and union values.  */
 
@@ -1101,19 +1079,6 @@ struct cum_arg
 
 #define ASM_PN_FORMAT "%s___%lu"
 
-/* Print an instruction operand X on file FILE.
-   Look in h8300.c for details.  */
-
-#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
-  ((CODE) == '#')
-
-#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
-
-/* Print a memory operand whose address is X, on file FILE.
-   This uses a function in h8300.c.  */
-
-#define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
-
 /* H8300 specific pragmas.  */
 #define REGISTER_TARGET_PRAGMAS()				\
   do								\
--- orig/gcc/config/h8300/h8300-protos.h	2009-05-14 19:12:45.000000000 +0530
+++ trunk/gcc/config/h8300/h8300-protos.h	2010-08-30 17:01:41.000000000 +0530
@@ -35,8 +35,6 @@ extern int compute_a_shift_cc (rtx, rtx 
 extern const char *output_a_rotate (enum rtx_code, rtx *);
 extern unsigned int compute_a_rotate_length (rtx *);
 extern const char *output_simode_bld (int, rtx[]);
-extern void print_operand_address (FILE *, rtx);
-extern void print_operand (FILE *, rtx, int);
 extern void final_prescan_insn (rtx, rtx *, int);
 extern int h8300_expand_movsi (rtx[]);
 extern void notice_update_cc (rtx, rtx);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [H8300] Hookize target macros
  2010-09-01  9:42 [H8300] Hookize target macros Naveen H. S
@ 2010-09-03 15:06 ` Richard Henderson
  2010-09-17 10:14   ` [PING]RE: " Naveen H. S
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2010-09-03 15:06 UTC (permalink / raw)
  To: Naveen H. S; +Cc: gcc-patches, Prafulla Thakare

On 09/01/2010 02:39 AM, Naveen H. S wrote:
> 	* config/h8300/h8300.c (h8300_print_operand_address): Make static.
> 	Adjust comments. Declare.
> 	(h8300_print_operand): Likewise.
> 	(h8300_print_operand_punct_valid_p): Moved from h8300.h file. 
> 	(h8300_function_value): Likewise.
> 	(h8300_function_value_regno_p): Likewise.
> 	(h8300_register_move_cost): Likewise.
> 	(TARGET_PRINT_OPERAND_PUNCT_VALID_P, TARGET_PRINT_OPERAND
> 	TARGET_PRINT_OPERAND_ADDRESS, TARGET_REGISTER_MOVE_COST
> 	TARGET_FUNCTION_VALUE, TARGET_FUNCTION_VALUE_REGNO_P): Define.
> 	* config/h8300/h8300.h (PRINT_OPERAND_ADDRESS, PRINT_OPERAND
> 	PRINT_OPERAND_PUNCT_VALID_P, REGISTER_MOVE_COST, FUNCTION_VALUE
> 	FUNCTION_VALUE_REGNO_P): Delete.
> 	* config/h8300/h8300-protos.h (print_operand): Delete.
> 	(print_operand_address): Delete.

Ok.


r~

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PING]RE: [H8300] Hookize target macros
  2010-09-03 15:06 ` Richard Henderson
@ 2010-09-17 10:14   ` Naveen H. S
  2011-04-01 17:25     ` Anatoly Sokolov
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen H. S @ 2010-09-17 10:14 UTC (permalink / raw)
  To: law; +Cc: gcc-patches, Richard Henderson, Prafulla Thakare

Hi,

Can you please commit the patch if it's OK?

Thanks & Regards,
Naveen

-----Original Message-----
From: Richard Henderson [mailto:rth@redhat.com] 
Sent: Friday, September 03, 2010 8:34 PM
To: Naveen H. S
Cc: gcc-patches@gcc.gnu.org; Prafulla Thakare
Subject: Re: [H8300] Hookize target macros

On 09/01/2010 02:39 AM, Naveen H. S wrote:
> 	* config/h8300/h8300.c (h8300_print_operand_address): Make static.
> 	Adjust comments. Declare.
> 	(h8300_print_operand): Likewise.
> 	(h8300_print_operand_punct_valid_p): Moved from h8300.h file. 
> 	(h8300_function_value): Likewise.
> 	(h8300_function_value_regno_p): Likewise.
> 	(h8300_register_move_cost): Likewise.
> 	(TARGET_PRINT_OPERAND_PUNCT_VALID_P, TARGET_PRINT_OPERAND
> 	TARGET_PRINT_OPERAND_ADDRESS, TARGET_REGISTER_MOVE_COST
> 	TARGET_FUNCTION_VALUE, TARGET_FUNCTION_VALUE_REGNO_P): Define.
> 	* config/h8300/h8300.h (PRINT_OPERAND_ADDRESS, PRINT_OPERAND
> 	PRINT_OPERAND_PUNCT_VALID_P, REGISTER_MOVE_COST, FUNCTION_VALUE
> 	FUNCTION_VALUE_REGNO_P): Delete.
> 	* config/h8300/h8300-protos.h (print_operand): Delete.
> 	(print_operand_address): Delete.

Ok.


r~


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PING]RE: [H8300] Hookize target macros
  2010-09-17 10:14   ` [PING]RE: " Naveen H. S
@ 2011-04-01 17:25     ` Anatoly Sokolov
  2011-04-01 17:28       ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Anatoly Sokolov @ 2011-04-01 17:25 UTC (permalink / raw)
  To: Naveen H. S; +Cc: law, gcc-patches, Richard Henderson, Prafulla Thakare, kazu

Hi.

On 09/17/2010 12:54:36, Naveen H. S wrote:
> Can you please commit the patch if it's OK?

> Thanks & Regards,
> Naveen

> -----Original Message-----
> From: Richard Henderson [mailto:rth@redhat.com] 
> Sent: Friday, September 03, 2010 8:34 PM
> To: Naveen H. S
> Cc: gcc-patches@gcc.gnu.org; Prafulla Thakare
> Subject: Re: [H8300] Hookize target macros

> On 09/01/2010 02:39 AM, Naveen H. S wrote:
>>       * config/h8300/h8300.c (h8300_print_operand_address): Make static.
>>       Adjust comments. Declare.
>>       (h8300_print_operand): Likewise.
>>       (h8300_print_operand_punct_valid_p): Moved from h8300.h file. 
>>       (h8300_function_value): Likewise.
>>       (h8300_function_value_regno_p): Likewise.
>>       (h8300_register_move_cost): Likewise.
>>       (TARGET_PRINT_OPERAND_PUNCT_VALID_P, TARGET_PRINT_OPERAND
>>       TARGET_PRINT_OPERAND_ADDRESS, TARGET_REGISTER_MOVE_COST
>>       TARGET_FUNCTION_VALUE, TARGET_FUNCTION_VALUE_REGNO_P): Define.
>>       * config/h8300/h8300.h (PRINT_OPERAND_ADDRESS, PRINT_OPERAND
>>       PRINT_OPERAND_PUNCT_VALID_P, REGISTER_MOVE_COST, FUNCTION_VALUE
>>       FUNCTION_VALUE_REGNO_P): Delete.
>>       * config/h8300/h8300-protos.h (print_operand): Delete.
>>       (print_operand_address): Delete.

> Ok.

> r~

  Since TARGET_FUNCTION_VALUE and TARGET_FUNCTION_VALUE_REGNO_P macros
already transformed in to target hooks, they are removed from this patch.
Also I add mark 'mode' argument in h8300_register_move_cost function as 
unused and slightly corrected ChangeLog entry.

  Because old patch is approved I will commit new version in four days is no 
objection.

  Regression tested on h8300-unknown-elf with no new failure.


2011-04-01  Naveen H.S  <naveen.S@kpitcummins.com>

        * config/h8300/h8300.c (print_operand_address): Rename to...
        (h8300_print_operand_address): ...this. Make static. Adjust comments.
        Call h8300_print_operand and h8300_print_operand_address instead of
        print_operand and print_operand_address. Declare.
        (print_operand): Renake to...
        (h8300_print_operand): ...this. Make static. Adjust comments.
        Call h8300_print_operand instead of print_operand. Declare.
        (h8300_print_operand_punct_valid_p): Moved from h8300.h file.
        (h8300_register_move_cost): Likewise.
        (TARGET_PRINT_OPERAND_PUNCT_VALID_P, TARGET_PRINT_OPERAND
        TARGET_PRINT_OPERAND_ADDRESS, TARGET_REGISTER_MOVE_COST): Define.
        * config/h8300/h8300.h (PRINT_OPERAND_ADDRESS, PRINT_OPERAND
        PRINT_OPERAND_PUNCT_VALID_P, REGISTER_MOVE_COST): Delete.
        * config/h8300/h8300-protos.h (print_operand): Delete.
        (print_operand_address): Delete

Index: gcc/config/h8300/h8300.c
===================================================================
--- gcc/config/h8300/h8300.c    (revision 171793)
+++ gcc/config/h8300/h8300.c    (working copy)
@@ -93,9 +93,13 @@
 static tree h8300_handle_fndecl_attribute (tree *, tree, tree, int, bool *);
 static tree h8300_handle_eightbit_data_attribute (tree *, tree, tree, int, bool *);
 static tree h8300_handle_tiny_data_attribute (tree *, tree, tree, int, bool *);
+static void h8300_print_operand_address (FILE *, rtx);
+static void h8300_print_operand (FILE *, rtx, int);
+static bool h8300_print_operand_punct_valid_p (unsigned char code);
 #ifndef OBJECT_FORMAT_ELF
 static void h8300_asm_named_section (const char *, unsigned int, tree);
 #endif
+static int h8300_register_move_cost (enum machine_mode, reg_class_t, reg_class_t);
 static int h8300_and_costs (rtx);
 static int h8300_shift_costs (rtx);
 static void          h8300_push_pop               (int, int, bool, bool);
@@ -1182,6 +1188,22 @@
 }
 
 \f
+/* Implements TARGET_REGISTER_MOVE_COST.
+
+   Any SI register-to-register move may need to be reloaded,
+   so inmplement h8300_register_move_cost to return > 2 so that reload never
+   shortcuts.  */
+
+static int
+h8300_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
+                         reg_class_t from, reg_class_t to)
+{
+  if (from == MAC_REGS || to == MAC_REG)
+    return 6;
+  else
+    return 3;
+}
+
 /* Compute the cost of an and insn.  */
 
 static int
@@ -1450,8 +1472,8 @@
 /* Print operand X using operand code CODE to assembly language output file
    FILE.  */
 
-void
-print_operand (FILE *file, rtx x, int code)
+static void
+h8300_print_operand (FILE *file, rtx x, int code)
 {
   /* This is used for communication between codes V,W,Z and Y.  */
   static int bitint;
@@ -1530,7 +1552,7 @@
       if (GET_CODE (x) == REG)
        fprintf (file, "%s%c", names_big[REGNO (x)], bitint > 7 ? 'h' : 'l');
       else
-       print_operand (file, x, 'R');
+       h8300_print_operand (file, x, 'R');
       bitint = -1;
       break;
     case 'Z':
@@ -1563,7 +1585,7 @@
            fprintf (file, "%s", names_upper_extended[REGNO (x)]);
          break;
        case MEM:
-         print_operand (file, x, 0);
+         h8300_print_operand (file, x, 0);
          break;
        case CONST_INT:
          fprintf (file, "#%ld", ((INTVAL (x) >> 16) & 0xffff));
@@ -1593,7 +1615,7 @@
          break;
        case MEM:
          x = adjust_address (x, HImode, 2);
-         print_operand (file, x, 0);
+         h8300_print_operand (file, x, 0);
          break;
        case CONST_INT:
          fprintf (file, "#%ld", INTVAL (x) & 0xffff);
@@ -1638,7 +1660,7 @@
        }
       break;
     case 'o':
-      print_operand_address (file, x);
+      h8300_print_operand_address (file, x);
       break;
     case 's':
       if (GET_CODE (x) == CONST_INT)
@@ -1755,7 +1777,7 @@
        case CONST:
        case LABEL_REF:
          fprintf (file, "#");
-         print_operand_address (file, x);
+         h8300_print_operand_address (file, x);
          break;
        case CONST_DOUBLE:
          {
@@ -1772,10 +1794,18 @@
     }
 }
 
+/* Implements TARGET_PRINT_OPERAND_PUNCT_VALID_P.  */
+
+static bool
+h8300_print_operand_punct_valid_p (unsigned char code)
+{
+  return (code == '#');
+}
+
 /* Output assembly language output for the address ADDR to FILE.  */
 
-void
-print_operand_address (FILE *file, rtx addr)
+static void
+h8300_print_operand_address (FILE *file, rtx addr)
 {
   rtx index;
   int size;
@@ -1809,37 +1839,37 @@
       if (GET_CODE (index) == REG)
        {
          /* reg,foo */
-         print_operand_address (file, XEXP (addr, 1));
+         h8300_print_operand_address (file, XEXP (addr, 1));
          fprintf (file, ",");
          switch (size)
            {
            case 0:
-             print_operand_address (file, index);
+             h8300_print_operand_address (file, index);
              break;
 
            case 1:
-             print_operand (file, index, 'X');
+             h8300_print_operand (file, index, 'X');
              fputs (".b", file);
              break;
 
            case 2:
-             print_operand (file, index, 'T');
+             h8300_print_operand (file, index, 'T');
              fputs (".w", file);
              break;
 
            case 4:
-             print_operand (file, index, 'S');
+             h8300_print_operand (file, index, 'S');
              fputs (".l", file);
              break;
            }
-         /* print_operand_address (file, XEXP (addr, 0)); */
+         /* h8300_print_operand_address (file, XEXP (addr, 0)); */
        }
       else
        {
          /* foo+k */
-         print_operand_address (file, XEXP (addr, 0));
+         h8300_print_operand_address (file, XEXP (addr, 0));
          fprintf (file, "+");
-         print_operand_address (file, XEXP (addr, 1));
+         h8300_print_operand_address (file, XEXP (addr, 1));
        }
       fprintf (file, ")");
       break;
@@ -3747,7 +3777,7 @@
 /* Return the asm template for a single h8sx shift instruction.
    OPERANDS[0] and OPERANDS[1] are the destination, OPERANDS[2]
    is the source and OPERANDS[3] is the shift.  SUFFIX is the
-   size suffix ('b', 'w' or 'l') and OPTYPE is the print_operand
+   size suffix ('b', 'w' or 'l') and OPTYPE is the h8300_print_operand
    prefix for the destination operand.  */
 
 const char *
@@ -5982,12 +6012,22 @@
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END h8300_file_end
 
+#undef TARGET_PRINT_OPERAND
+#define TARGET_PRINT_OPERAND h8300_print_operand
+#undef TARGET_PRINT_OPERAND_ADDRESS
+#define TARGET_PRINT_OPERAND_ADDRESS h8300_print_operand_address
+#undef TARGET_PRINT_OPERAND_PUNCT_VALID_P
+#define TARGET_PRINT_OPERAND_PUNCT_VALID_P h8300_print_operand_punct_valid_p
+
 #undef TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO h8300_encode_section_info
 
 #undef TARGET_INSERT_ATTRIBUTES
 #define TARGET_INSERT_ATTRIBUTES h8300_insert_attributes
 
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST h8300_register_move_cost
+
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS h8300_rtx_costs
 
Index: gcc/config/h8300/h8300.h
===================================================================
--- gcc/config/h8300/h8300.h    (revision 171793)
+++ gcc/config/h8300/h8300.h    (working copy)
@@ -435,13 +435,6 @@
 #define CLASS_MAX_NREGS(CLASS, MODE)   \
   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
 
-/* Any SI register-to-register move may need to be reloaded,
-   so define REGISTER_MOVE_COST to be > 2 so that reload never
-   shortcuts.  */
-
-#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2)  \
-  (CLASS1 == MAC_REGS || CLASS2 == MAC_REGS ? 6 : 3)
-\f
 /* Stack layout; function entry, exit and calling.  */
 
 /* Define this if pushing a word on the stack
@@ -977,19 +970,6 @@
 
 #define ASM_PN_FORMAT "%s___%lu"
 
-/* Print an instruction operand X on file FILE.
-   Look in h8300.c for details.  */
-
-#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
-  ((CODE) == '#')
-
-#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
-
-/* Print a memory operand whose address is X, on file FILE.
-   This uses a function in h8300.c.  */
-
-#define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
-
 /* H8300 specific pragmas.  */
 #define REGISTER_TARGET_PRAGMAS()                              \
   do                                                           \
Index: gcc/config/h8300/h8300-protos.h
===================================================================
--- gcc/config/h8300/h8300-protos.h     (revision 171793)
+++ gcc/config/h8300/h8300-protos.h     (working copy)
@@ -34,8 +34,6 @@
 extern const char *output_a_rotate (enum rtx_code, rtx *);
 extern unsigned int compute_a_rotate_length (rtx *);
 extern const char *output_simode_bld (int, rtx[]);
-extern void print_operand_address (FILE *, rtx);
-extern void print_operand (FILE *, rtx, int);
 extern void final_prescan_insn (rtx, rtx *, int);
 extern int h8300_expand_movsi (rtx[]);
 extern void notice_update_cc (rtx, rtx);


Anatoly.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PING]RE: [H8300] Hookize target macros
  2011-04-01 17:25     ` Anatoly Sokolov
@ 2011-04-01 17:28       ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2011-04-01 17:28 UTC (permalink / raw)
  To: Anatoly Sokolov; +Cc: Naveen H. S, law, gcc-patches, Prafulla Thakare, kazu

On 04/01/2011 10:25 AM, Anatoly Sokolov wrote:
>         * config/h8300/h8300.c (print_operand_address): Rename to...
>         (h8300_print_operand_address): ...this. Make static. Adjust comments.
>         Call h8300_print_operand and h8300_print_operand_address instead of
>         print_operand and print_operand_address. Declare.
>         (print_operand): Renake to...
>         (h8300_print_operand): ...this. Make static. Adjust comments.
>         Call h8300_print_operand instead of print_operand. Declare.
>         (h8300_print_operand_punct_valid_p): Moved from h8300.h file.
>         (h8300_register_move_cost): Likewise.
>         (TARGET_PRINT_OPERAND_PUNCT_VALID_P, TARGET_PRINT_OPERAND
>         TARGET_PRINT_OPERAND_ADDRESS, TARGET_REGISTER_MOVE_COST): Define.
>         * config/h8300/h8300.h (PRINT_OPERAND_ADDRESS, PRINT_OPERAND
>         PRINT_OPERAND_PUNCT_VALID_P, REGISTER_MOVE_COST): Delete.
>         * config/h8300/h8300-protos.h (print_operand): Delete.
>         (print_operand_address): Delete

The new patch is ok too.


r~

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-01 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-01  9:42 [H8300] Hookize target macros Naveen H. S
2010-09-03 15:06 ` Richard Henderson
2010-09-17 10:14   ` [PING]RE: " Naveen H. S
2011-04-01 17:25     ` Anatoly Sokolov
2011-04-01 17:28       ` Richard Henderson

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).