h8300.h (CONST_OK_FOR_J): Remove.
[platform/upstream/gcc.git] / gcc / config / h8300 / h8300.h
index d0db90a..902517d 100644 (file)
@@ -42,19 +42,27 @@ extern const char * const *h8_reg_names;
   do                                                   \
     {                                                  \
       if (TARGET_H8300H)                               \
-        {                                              \
+                                                     \
          builtin_define ("__H8300H__");                \
          builtin_assert ("cpu=h8300h");                \
          builtin_assert ("machine=h8300h");            \
+         if (TARGET_NORMAL_MODE)                       \
+           {                                           \
+             builtin_define ("__NORMAL_MODE__");       \
+           }                                           \
        }                                               \
       else if (TARGET_H8300S)                          \
-        {                                              \
+                                                     \
          builtin_define ("__H8300S__");                \
          builtin_assert ("cpu=h8300s");                \
          builtin_assert ("machine=h8300s");            \
+         if (TARGET_NORMAL_MODE)                       \
+           {                                           \
+             builtin_define ("__NORMAL_MODE__");       \
+           }                                           \
        }                                               \
       else                                             \
-        {                                              \
+                                                     \
          builtin_define ("__H8300__");                 \
          builtin_assert ("cpu=h8300");                 \
          builtin_assert ("machine=h8300");             \
@@ -66,14 +74,14 @@ extern const char * const *h8_reg_names;
 
 #define LIB_SPEC "%{mrelax:-relax} %{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
 
-#define OPTIMIZATION_OPTIONS(LEVEL, SIZE)                                \
-  do                                                                     \
-    {                                                                     \
-      /* Basic block reordering is only beneficial on targets with cache  \
-        and/or variable-cycle branches where (cycle count taken !=       \
-        cycle count not taken).  */                                      \
-      flag_reorder_blocks = 0;                                           \
-    }                                                                    \
+#define OPTIMIZATION_OPTIONS(LEVEL, SIZE)                               \
+  do                                                                    \
+    {                                                                   \
+      /* Basic block reordering is only beneficial on targets with cache \
+        and/or variable-cycle branches where (cycle count taken !=      \
+        cycle count not taken).  */                                     \
+      flag_reorder_blocks = 0;                                          \
+    }                                                                   \
   while (0)
 
 /* Print subsidiary information on the compiler version in use.  */
@@ -91,6 +99,7 @@ extern int target_flags;
 #define MASK_ADDRESSES         0x00000040
 #define MASK_QUICKCALL         0x00000080
 #define MASK_SLOWBYTE          0x00000100
+#define MASK_NORMAL_MODE       0x00000200
 #define MASK_RELAX             0x00000400
 #define MASK_RTL_DUMP          0x00000800
 #define MASK_H8300H            0x00001000
@@ -119,13 +128,14 @@ extern int target_flags;
 #define TARGET_H8300   (! TARGET_H8300H && ! TARGET_H8300S)
 #define TARGET_H8300H  (target_flags & MASK_H8300H)
 #define TARGET_H8300S  (target_flags & MASK_H8300S)
+#define TARGET_NORMAL_MODE (target_flags & MASK_NORMAL_MODE)
 
 /* mac register and relevant instructions are available.  */
 #define TARGET_MAC    (target_flags & MASK_MAC)
 
 /* Align all values on the H8/300H the same way as the H8/300.  Specifically,
    32 bit and larger values are aligned on 16 bit boundaries.
-   This is all the hardware requires, but the default is 32 bits for the 300H.
+   This is all the hardware requires, but the default is 32 bits for the H8/300H.
    ??? Now watch someone add hardware floating point requiring 32 bit
    alignment.  */
 #define TARGET_ALIGN_300 (target_flags & MASK_ALIGN_300)
@@ -152,6 +162,7 @@ extern int target_flags;
   {"relax",             MASK_RELAX, N_("Enable linker relaxing")},         \
   {"rtl-dump",          MASK_RTL_DUMP, NULL},                              \
   {"h",                         MASK_H8300H, N_("Generate H8/300H code")},         \
+  {"n",                         MASK_NORMAL_MODE, N_("Enable the normal mode")},   \
   {"no-h",             -MASK_H8300H, N_("Do not generate H8/300H code")},  \
   {"align-300",                 MASK_ALIGN_300, N_("Use H8/300 alignment rules")}, \
   { "",                         TARGET_DEFAULT, NULL}}
@@ -159,6 +170,7 @@ extern int target_flags;
 #ifdef IN_LIBGCC2
 #undef TARGET_H8300H
 #undef TARGET_H8300S
+#undef TARGET_NORMAL_MODE
 /* If compiling libgcc2, make these compile time constants based on what
    flags are we actually compiling with.  */
 #ifdef __H8300H__
@@ -171,6 +183,11 @@ extern int target_flags;
 #else
 #define TARGET_H8300S  0
 #endif
+#ifdef __NORMAL_MODE__
+#define TARGET_NORMAL_MODE 1
+#else
+#define TARGET_NORMAL_MODE 0
+#endif
 #endif /* !IN_LIBGCC2 */
 
 /* Do things that must be done once at start up.  */
@@ -444,13 +461,10 @@ enum reg_class {
    Return 1 if VALUE is in the range specified by C.  */
 
 #define CONST_OK_FOR_I(VALUE) ((VALUE) == 0)
-#define CONST_OK_FOR_J(VALUE) ((unsigned HOST_WIDE_INT) (VALUE) < 256)
-#define CONST_OK_FOR_K(VALUE) ((VALUE) == 1 || (VALUE) == 2)
 #define CONST_OK_FOR_L(VALUE)                          \
   (TARGET_H8300H || TARGET_H8300S                      \
    ? (VALUE) == 1 || (VALUE) == 2 || (VALUE) == 4      \
    : (VALUE) == 1 || (VALUE) == 2)
-#define CONST_OK_FOR_M(VALUE) ((VALUE) == 3 || (VALUE) == 4)
 #define CONST_OK_FOR_N(VALUE)                          \
   (TARGET_H8300H || TARGET_H8300S                      \
    ? (VALUE) == -1 || (VALUE) == -2 || (VALUE) == -4   \
@@ -458,10 +472,7 @@ enum reg_class {
 
 #define CONST_OK_FOR_LETTER_P(VALUE, C)                \
   ((C) == 'I' ? CONST_OK_FOR_I (VALUE) :       \
-   (C) == 'J' ? CONST_OK_FOR_J (VALUE) :       \
-   (C) == 'K' ? CONST_OK_FOR_K (VALUE) :       \
    (C) == 'L' ? CONST_OK_FOR_L (VALUE) :       \
-   (C) == 'M' ? CONST_OK_FOR_M (VALUE) :       \
    (C) == 'N' ? CONST_OK_FOR_N (VALUE) :       \
    0)
 
@@ -575,10 +586,7 @@ enum reg_class {
    All other eliminations are valid.  */
 
 #define CAN_ELIMINATE(FROM, TO)                                        \
- ((((FROM) == ARG_POINTER_REGNUM || (FROM) == RETURN_ADDRESS_POINTER_REGNUM) \
-   && (TO) == STACK_POINTER_REGNUM)                            \
-  ? ! frame_pointer_needed                                     \
-  : 1)
+  ((TO) == STACK_POINTER_REGNUM ? ! frame_pointer_needed : 1)
 
 /* Define the offset between two registers, one to be eliminated, and the other
    its replacement, at the start of a routine.  */
@@ -844,18 +852,6 @@ struct cum_arg
    ? !h8300_shift_needs_scratch_p (INTVAL (OP), SImode)        \
    : 0)
 
-/* Nonzero if X is a constant address suitable as an 8-bit absolute,
-   which is a special case of the 'R' operand.  */
-
-#define EIGHTBIT_CONSTANT_ADDRESS_P(X)         \
-  h8300_eightbit_constant_address_p (X)
-
-/* Nonzero if X is a constant address suitable as an 16-bit absolute
-   on H8/300H and H8S.  */
-
-#define TINY_CONSTANT_ADDRESS_P(X)             \
-  h8300_tiny_constant_address_p (X)
-
 /* 'U' if valid for a bset destination;
    i.e. a register, register indirect, or the eightbit memory region
    (a SYMBOL_REF with an SYMBOL_REF_FLAG set).
@@ -866,15 +862,15 @@ struct cum_arg
    || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == REG          \
        && REG_OK_FOR_BASE_P (XEXP (OP, 0)))                            \
    || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == SYMBOL_REF   \
-       && (TARGET_H8300S || SYMBOL_REF_FLAG (XEXP (OP, 0))))           \
-   || ((GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == CONST       \
-        && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS                   \
-        && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == SYMBOL_REF   \
-        && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT)   \
-        && (TARGET_H8300S                                              \
-           || SYMBOL_REF_FLAG (XEXP (XEXP (XEXP (OP, 0), 0), 0))))     \
+       && TARGET_H8300S)                                               \
+   || (GET_CODE (OP) == MEM && GET_CODE (XEXP (OP, 0)) == CONST                \
+       && GET_CODE (XEXP (XEXP (OP, 0), 0)) == PLUS                    \
+       && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 0)) == SYMBOL_REF    \
+       && GET_CODE (XEXP (XEXP (XEXP (OP, 0), 0), 1)) == CONST_INT     \
+       && (TARGET_H8300S                                               \
+          || SYMBOL_REF_FLAG (XEXP (XEXP (XEXP (OP, 0), 0), 0))))      \
    || (GET_CODE (OP) == MEM                                            \
-       && EIGHTBIT_CONSTANT_ADDRESS_P (XEXP (OP, 0)))                  \
+       && h8300_eightbit_constant_address_p (XEXP (OP, 0)))            \
    || (GET_CODE (OP) == MEM && TARGET_H8300S                           \
        && GET_CODE (XEXP (OP, 0)) == CONST_INT))
 
@@ -977,13 +973,19 @@ struct cum_arg
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
    between pointers and any other objects of this machine mode.  */
-#define Pmode (TARGET_H8300H || TARGET_H8300S ? SImode : HImode)
+#define Pmode                                                                \
+  ((TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE ? SImode : HImode)
 
 /* ANSI C types.
-   We use longs for the 300H because ints can be 16 or 32.
+   We use longs for the H8/300H and the H8S because ints can be 16 or 32.
    GCC requires SIZE_TYPE to be the same size as pointers.  */
-#define SIZE_TYPE (TARGET_H8300 ? "unsigned int" : "long unsigned int")
-#define PTRDIFF_TYPE (TARGET_H8300 ? "int" : "long int")
+#define SIZE_TYPE                                                              \
+  (TARGET_H8300 || TARGET_NORMAL_MODE ? "unsigned int" : "long unsigned int")
+#define PTRDIFF_TYPE                                           \
+  (TARGET_H8300 || TARGET_NORMAL_MODE ? "int" : "long int")
+
+#define POINTER_SIZE                                                   \
+  ((TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE ? 32 : 16)
 
 #define WCHAR_TYPE "short unsigned int"
 #define WCHAR_TYPE_SIZE 16
@@ -1012,20 +1014,22 @@ struct cum_arg
 
 /* Provide the costs of a rtl expression.  This is in the body of a
    switch on CODE.  */
-/* ??? Shifts need to have a *much* higher cost than this.  */
-
-#define RTX_COSTS(RTX, CODE, OUTER_CODE)       \
-  case MOD:                                    \
-  case DIV:                                    \
-    return 60;                                 \
-  case MULT:                                   \
-    return 20;                                 \
-  case ASHIFT:                                 \
-  case ASHIFTRT:                               \
-  case LSHIFTRT:                               \
-  case ROTATE:                                 \
-  case ROTATERT:                               \
-    if (GET_MODE (RTX) == HImode) return 2;    \
+
+#define RTX_COSTS(RTX, CODE, OUTER_CODE)               \
+  case AND:                                            \
+    return COSTS_N_INSNS (h8300_and_costs (RTX));      \
+  case MOD:                                            \
+  case DIV:                                            \
+    return 60;                                         \
+  case MULT:                                           \
+    return 20;                                         \
+  case ASHIFT:                                         \
+  case ASHIFTRT:                                       \
+  case LSHIFTRT:                                       \
+    return COSTS_N_INSNS (h8300_shift_costs (RTX));    \
+  case ROTATE:                                         \
+  case ROTATERT:                                       \
+    if (GET_MODE (RTX) == HImode) return 2;            \
     return 8;
 
 /* Tell final.c how to eliminate redundant test instructions.  */
@@ -1071,7 +1075,8 @@ struct cum_arg
 #define IDENT_ASM_OP "\t.ident\n"
 
 /* The assembler op to get a word, 2 bytes for the H8/300, 4 for H8/300H.  */
-#define ASM_WORD_OP    (TARGET_H8300 ? "\t.word\t" : "\t.long\t")
+#define ASM_WORD_OP                                                    \
+  (TARGET_H8300 || TARGET_NORMAL_MODE ? "\t.word\t" : "\t.long\t")
 
 #define TEXT_SECTION_ASM_OP "\t.section .text"
 #define DATA_SECTION_ASM_OP "\t.section .data"