This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] h8300 port: Add 16-bit constant address support.
- From: Kazu Hirata <kazu at hxi dot com>
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] h8300 port: Add 16-bit constant address support.
Hi,
Attached is a patch to add 16-bit constant address support.
Tested on h8300 port. Committed.
Kazu Hirata
2002-03-01 Kazu Hirata <kazu@hxi.com>
* config/h8300/h8300.c (print_operand): Support 16-bit
constant addresses.
* config/h8300/h8300.h (TINY_CONSTANT_ADDRESS_P): New.
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.123
diff -c -r1.123 h8300.c
*** h8300.c 2002/02/28 18:13:05 1.123
--- h8300.c 2002/03/01 08:54:06
***************
*** 1206,1228 ****
case MEM:
{
rtx addr = XEXP (x, 0);
fprintf (file, "@");
output_address (addr);
! /* If this is an 'R' operand (reference into the 8-bit
! area), then specify a symbolic address as "foo:8",
! otherwise if operand is still in eight bit section, use
! "foo:16". */
! if (GET_CODE (addr) == SYMBOL_REF
! && SYMBOL_REF_FLAG (addr))
! fprintf (file, (code == 'R' ? ":8" : ":16"));
! else if (GET_CODE (addr) == SYMBOL_REF
! && TINY_DATA_NAME_P (XSTR (addr, 0)))
! fprintf (file, ":16");
! else if ((code == 'R')
! && EIGHTBIT_CONSTANT_ADDRESS_P (addr))
! fprintf (file, ":8");
}
break;
--- 1206,1247 ----
case MEM:
{
rtx addr = XEXP (x, 0);
+ int eightbit_ok = ((GET_CODE (addr) == SYMBOL_REF
+ && SYMBOL_REF_FLAG (addr))
+ || EIGHTBIT_CONSTANT_ADDRESS_P (addr));
+ int tiny_ok = ((GET_CODE (addr) == SYMBOL_REF
+ && TINY_DATA_NAME_P (XSTR (addr, 0)))
+ || TINY_CONSTANT_ADDRESS_P (addr));
fprintf (file, "@");
output_address (addr);
! /* We fall back from smaller addressing to larger
! addressing in various ways depending on CODE. */
! switch (code)
! {
! case 'R':
! /* Used for mov.b and bit operations. */
! if (eightbit_ok)
! {
! fprintf (file, ":8");
! break;
! }
!
! /* Fall through. We should not get here if we are
! processing bit operations on H8/300 or H8/300H
! because 'U' constraint does not allow bit
! operations on the tiny area on these machines. */
!
! case 'T':
! case 'S':
! /* Used for mov.w and mov.l. */
! if (tiny_ok)
! fprintf (file, ":16");
! break;
! default:
! break;
! }
}
break;
Index: h8300.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.h,v
retrieving revision 1.79
diff -c -r1.79 h8300.h
*** h8300.h 2002/02/28 18:13:06 1.79
--- h8300.h 2002/03/01 08:54:07
***************
*** 860,865 ****
--- 860,873 ----
(GET_CODE (X) == CONST_INT && TARGET_H8300H \
&& 0xffff00 <= INTVAL (X) && INTVAL (X) <= 0xffffff)
+ /* Nonzero if X is a constant address suitable as an 16-bit absolute
+ on the H8/300H. */
+
+ #define TINY_CONSTANT_ADDRESS_P(X) \
+ (GET_CODE (X) == CONST_INT && TARGET_H8300H \
+ && ((0xff8000 <= INTVAL (X) && INTVAL (X) <= 0xffffff) \
+ || (0x000000 <= INTVAL (X) && INTVAL (X) <= 0x007fff)))
+
/* '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).