Patchwork [PING] RE: [H8300] Hookize target macros

login
register
mail settings
Submitter Anatoly Sokolov
Date April 1, 2011, 5:25 p.m.
Message ID <307633434.20110401212547@post.ru>
Download mbox | patch
Permalink /patch/89310/
State New
Headers show

Comments

Anatoly Sokolov - April 1, 2011, 5:25 p.m.
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



Anatoly.
Richard Henderson - April 1, 2011, 5:28 p.m.
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~

Patch

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 @@ 
 }
 
 
+/* 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)
-
 /* 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);