From 803d56f52a6eee9870b0f5c821f2bc24b025bf0a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 29 Oct 2002 17:55:45 +0000 Subject: [PATCH] h8300.c (h8300_eightbit_constant_address_p): New. * 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 | 10 +++++++ gcc/config/h8300/h8300-protos.h | 3 ++ gcc/config/h8300/h8300.c | 53 +++++++++++++++++++++++++++++++++ gcc/config/h8300/h8300.h | 21 +++---------- 4 files changed, 70 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95f304f8820..3fb826f2c39 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2002-10-29 Kazu Hirata + + * 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 * reload1.c (update_eliminables): Unconditionally check if diff --git a/gcc/config/h8300/h8300-protos.h b/gcc/config/h8300/h8300-protos.h index c786f9f6f48..b88ade053bb 100644 --- a/gcc/config/h8300/h8300-protos.h +++ b/gcc/config/h8300/h8300-protos.h @@ -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 */ diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 8461d5c06af..55ac700ddca 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -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))); +} diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index 927484a6ba3..1e4b1ddf0ee 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -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