h8300.c (h8300_eightbit_constant_address_p): New.
authorKazu Hirata <kazu@cs.umass.edu>
Tue, 29 Oct 2002 17:55:45 +0000 (17:55 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Tue, 29 Oct 2002 17:55:45 +0000 (17:55 +0000)
* config/h8300/h8300.c (h8300_eightbit_constant_address_p): New.
(h8300_tiny_constant_address_p): Likewise.
* config/h8300/h8300.h (EIGHTBIT_CONSTANT_ADDRESS_P): Use
h8300_eightbit_constant_address_p.
(TINY_CONSTANT_ADDRESS_P): Use h8300_tiny_constant_address_p.
* config/h8300/h8300-protos.h: Add the prototypes for the two
new functions.

From-SVN: r58628

gcc/ChangeLog
gcc/config/h8300/h8300-protos.h
gcc/config/h8300/h8300.c
gcc/config/h8300/h8300.h

index 95f304f8820188042a904bb0158655271d95cb48..3fb826f2c390932fd5f57b9ee1a7edf381941040 100644 (file)
@@ -1,3 +1,13 @@
+2002-10-29  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * config/h8300/h8300.c (h8300_eightbit_constant_address_p): New.
+       (h8300_tiny_constant_address_p): Likewise.
+       * config/h8300/h8300.h (EIGHTBIT_CONSTANT_ADDRESS_P): Use
+       h8300_eightbit_constant_address_p.
+       (TINY_CONSTANT_ADDRESS_P): Use h8300_tiny_constant_address_p.
+       * config/h8300/h8300-protos.h: Add the prototypes for the two
+       new functions.
+
 2002-10-29  Kazu Hirata  <kazu@cs.umass.edu>
 
        * reload1.c (update_eliminables): Unconditionally check if
index c786f9f6f48543c4ae90bc60e4767207ce829062..b88ade053bb0897296a9de4038cf241eea8ca285 100644 (file)
@@ -60,6 +60,9 @@ extern int bit_memory_operand PARAMS ((rtx, enum machine_mode));
 extern int bit_operator PARAMS ((rtx, enum machine_mode));
 extern int nshift_operator PARAMS ((rtx, enum machine_mode));
 
+extern int h8300_eightbit_constant_address_p PARAMS ((rtx));
+extern int h8300_tiny_constant_address_p PARAMS ((rtx));
+
 /* Used in builtins.c */
 extern rtx h8300_return_addr_rtx PARAMS ((int, rtx));
 #endif /* RTX_CODE */
index 8461d5c06af5352decdccffb3ac66ea500a725f6..55ac700ddcaa845fc793ec19524de7f27ea298c8 100644 (file)
@@ -3856,3 +3856,56 @@ h8300_asm_named_section (name, flags)
   fprintf (asm_out_file, "\t.section %s\n", name);
 }
 #endif /* ! OBJECT_FORMAT_ELF */
+
+int
+h8300_eightbit_constant_address_p (x)
+     rtx x;
+{
+  /* The ranges the 8-bit area. */
+  const unsigned HOST_WIDE_INT n1 = trunc_int_for_mode (0x0000ff00, SImode);
+  const unsigned HOST_WIDE_INT n2 = trunc_int_for_mode (0x0000ffff, SImode);
+  const unsigned HOST_WIDE_INT h1 = trunc_int_for_mode (0x00ffff00, SImode);
+  const unsigned HOST_WIDE_INT h2 = trunc_int_for_mode (0x00ffffff, SImode);
+  const unsigned HOST_WIDE_INT s1 = trunc_int_for_mode (0xffffff00, SImode);
+  const unsigned HOST_WIDE_INT s2 = trunc_int_for_mode (0xffffffff, SImode);
+
+  unsigned HOST_WIDE_INT addr;
+
+  if (GET_CODE (x) != CONST_INT)
+    return 0;
+
+  addr = INTVAL (x);
+
+  return (0
+         || (TARGET_H8300  && IN_RANGE (addr, n1, n2))
+         || (TARGET_H8300H && IN_RANGE (addr, h1, h2))
+         || (TARGET_H8300S && IN_RANGE (addr, s1, s2)));
+}
+
+int
+h8300_tiny_constant_address_p (x)
+     rtx x;
+{
+  /* The ranges for the 16-bit area.  */
+  const unsigned HOST_WIDE_INT h1 = trunc_int_for_mode (0x00000000, SImode);
+  const unsigned HOST_WIDE_INT h2 = trunc_int_for_mode (0x00007fff, SImode);
+  const unsigned HOST_WIDE_INT h3 = trunc_int_for_mode (0x00ff8000, SImode);
+  const unsigned HOST_WIDE_INT h4 = trunc_int_for_mode (0x00ffffff, SImode);
+  const unsigned HOST_WIDE_INT s1 = trunc_int_for_mode (0x00000000, SImode);
+  const unsigned HOST_WIDE_INT s2 = trunc_int_for_mode (0x00007fff, SImode);
+  const unsigned HOST_WIDE_INT s3 = trunc_int_for_mode (0xffff8000, SImode);
+  const unsigned HOST_WIDE_INT s4 = trunc_int_for_mode (0xffffffff, SImode);
+
+  unsigned HOST_WIDE_INT addr;
+
+  if (GET_CODE (x) != CONST_INT)
+    return 0;
+
+  addr = INTVAL (x);
+
+  return (0
+         || (TARGET_H8300H
+             && IN_RANGE (addr, h1, h2) || IN_RANGE (addr, h3, h4))
+         || (TARGET_H8300S
+             && IN_RANGE (addr, s1, s2) || IN_RANGE (addr, s3, s4)));
+}
index 927484a6ba3bafebdbcdfd0301cbecfd632d5883..1e4b1ddf0ee2b76227f2bfb777c7eb0f4dbc1991 100644 (file)
@@ -837,27 +837,14 @@ struct cum_arg
 /* 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)                                 \
-  ((GET_CODE (X) == CONST_INT)                                         \
-   && ((TARGET_H8300 && IN_RANGE (INTVAL (X) & 0xffff, 0xff00, 0xffff))        \
-       || (TARGET_H8300H && IN_RANGE (INTVAL (X) & 0xffffffff,         \
-                                     0xffff00, 0xffffff))              \
-       || (TARGET_H8300S && IN_RANGE (INTVAL (X) & 0xffffffff,         \
-                                     0xffffff00, 0xffffffff))))
+#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)                                     \
-  ((GET_CODE (X) == CONST_INT)                                         \
-   && ((TARGET_H8300H                                                  \
-       && (IN_RANGE (INTVAL (X) & 0xffffffff, 0x000000, 0x007fff)      \
-           || IN_RANGE (INTVAL (X) & 0xffffffff, 0xff8000, 0xffffff))) \
-       || (TARGET_H8300S                                               \
-          && (IN_RANGE (INTVAL (X) & 0xffffffff,                       \
-                        0x00000000, 0x00007fff)                        \
-              || IN_RANGE (INTVAL (X) & 0xffffffff,                    \
-                           0xffff8000, 0xffffffff)))))
+#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