This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: NORMAL MODE PATCH for Gcc 3.3
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: VijayK1 at kpit dot com
- Cc: gcc-patches at gcc dot gnu dot org, gnuh8 at gnuh8 dot org dot uk
- Date: Tue, 24 Sep 2002 10:30:43 -0400 (EDT)
- Subject: Re: NORMAL MODE PATCH for Gcc 3.3
- References: <69595093233BB547BB70CF5E492B63F276070B@sohm.kpit.com>
Hi Vijay,
> Please find the patches for normal mode support in gcc 3.3.I played
> with UNITS_PER_WORD but needed to introduce pointer size again. The
> testing is done on HDI simulator. Let me know the bugs if any body
> finds one.
Thank you for updating the patch to be against the trunk.
Now, why do you still have to have "offset -= 2;" even though you have
pretty complete support for Pmode, POINTER_SIZE, etc? This seems to
be a hack a little bit.
By the way, I fixed the formatting problems and the like. Please
provide a ChangeLog entry.
Kazu Hirata
Index: config/h8300/h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.148
diff -c -r1.148 h8300.c
*** config/h8300/h8300.c 24 Sep 2002 12:48:54 -0000 1.148
--- config/h8300/h8300.c 24 Sep 2002 14:28:56 -0000
***************
*** 315,320 ****
--- 315,326 ----
target_flags |= 1;
}
+ if (TARGET_H8300 && TARGET_NORMAL_MODE)
+ {
+ error ("-mn is used without -mh or -ms");
+ target_flags ^=512;
+ }
+
/* Some of the shifts are optimized for speed by default.
See http://gcc.gnu.org/ml/gcc-patches/2002-07/msg01858.html
If optimizing for size, change shift_alg for those shift to
***************
*** 1635,1640 ****
--- 1641,1650 ----
if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
offset += UNITS_PER_WORD; /* Skip saved PC */
}
+
+ if ((TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE)
+ offset -= 2;
+
return offset;
}
Index: config/h8300/h8300.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.h,v
retrieving revision 1.104
diff -c -r1.104 h8300.h
*** config/h8300/h8300.h 24 Sep 2002 12:48:54 -0000 1.104
--- config/h8300/h8300.h 24 Sep 2002 14:28:58 -0000
***************
*** 46,57 ****
--- 46,61 ----
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 \
{ \
***************
*** 97,102 ****
--- 101,107 ----
#define TARGET_H8300 (! TARGET_H8300H && ! TARGET_H8300S)
#define TARGET_H8300H (target_flags & 4096)
#define TARGET_H8300S (target_flags & 1)
+ #define TARGET_NORMAL_MODE (target_flags & 512)
/* mac register and relevant instructions are available. */
#define TARGET_MAC (target_flags & 2)
***************
*** 130,135 ****
--- 135,141 ----
{"relax", 1024, N_("Enable linker relaxing")}, \
{"rtl-dump", 2048, NULL}, \
{"h", 4096, N_("Generate H8/300H code")}, \
+ {"n", 512, N_("Enable Normal Mode")}, \
{"no-h", -4096, N_("Do not generate H8/300H code")}, \
{"align-300", 8192, N_("Use H8/300 alignment rules")}, \
{ "", TARGET_DEFAULT, NULL}}
***************
*** 137,142 ****
--- 143,149 ----
#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__
***************
*** 149,154 ****
--- 156,166 ----
#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. */
***************
*** 758,765 ****
(GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
|| (GET_CODE (X) == CONST_INT \
/* We handle signed and unsigned offsets here. */ \
! && INTVAL (X) > (TARGET_H8300 ? -0x10000 : -0x1000000) \
! && INTVAL (X) < (TARGET_H8300 ? 0x10000 : 0x1000000)) \
|| ((GET_CODE (X) == HIGH || GET_CODE (X) == CONST) \
&& TARGET_H8300))
--- 770,777 ----
(GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
|| (GET_CODE (X) == CONST_INT \
/* We handle signed and unsigned offsets here. */ \
! && INTVAL (X) > (TARGET_H8300 || TARGET_NORMAL_MODE ? -0x10000 : -0x1000000) \
! && INTVAL (X) < (TARGET_H8300 || TARGET_NORMAL_MODE ? 0x10000 : 0x1000000)) \
|| ((GET_CODE (X) == HIGH || GET_CODE (X) == CONST) \
&& TARGET_H8300))
***************
*** 845,851 ****
|| (TARGET_H8300S \
&& ((0xffff8000 <= INTVAL (X) && INTVAL (X) <= 0xffffffff) \
|| (0x00000000 <= INTVAL (X) \
! && INTVAL (X) <= 0x00007fff)))))
/* 'U' if valid for a bset destination;
i.e. a register, register indirect, or the eightbit memory region
--- 857,864 ----
|| (TARGET_H8300S \
&& ((0xffff8000 <= INTVAL (X) && INTVAL (X) <= 0xffffffff) \
|| (0x00000000 <= INTVAL (X) \
! && INTVAL (X) <= 0x00007fff))) \
! || TARGET_NORMAL_MODE))
/* 'U' if valid for a bset destination;
i.e. a register, register indirect, or the eightbit memory region
***************
*** 968,980 ****
/* 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)
/* ANSI C types.
We use longs for the 300H 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 WCHAR_TYPE "short unsigned int"
#define WCHAR_TYPE_SIZE 16
--- 981,995 ----
/* 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) && !TARGET_NORMAL_MODE ? SImode : HImode)
/* ANSI C types.
We use longs for the 300H because ints can be 16 or 32.
GCC requires SIZE_TYPE to be the same size as pointers. */
! #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
***************
*** 1062,1068 ****
#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 TEXT_SECTION_ASM_OP "\t.section .text"
#define DATA_SECTION_ASM_OP "\t.section .data"
--- 1077,1083 ----
#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 || 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"
Index: config/h8300/h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.94
diff -c -r1.94 h8300.md
*** config/h8300/h8300.md 24 Sep 2002 12:48:54 -0000 1.94
--- config/h8300/h8300.md 24 Sep 2002 14:28:59 -0000
***************
*** 1506,1511 ****
--- 1506,1519 ----
[(set_attr "cc" "none")
(set_attr "length" "2")])
+ (define_insn "tablejump_normal_mode"
+ [(set (pc) (match_operand:HI 0 "register_operand" "r"))
+ (use (label_ref (match_operand 1 "" "")))]
+ "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
+ "jmp @%S0"
+ [(set_attr "cc" "none")
+ (set_attr "length" "2")])
+
;; This is a define expand, because pointers may be either 16 or 32 bits.
(define_expand "indirect_jump"
***************
*** 1524,1529 ****
--- 1532,1544 ----
[(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
"TARGET_H8300H || TARGET_H8300S"
"jmp @%0"
+ [(set_attr "cc" "none")
+ (set_attr "length" "2")])
+
+ (define_insn "indirect_jump_normal_mode"
+ [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
+ "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
+ "jmp @%S0"
[(set_attr "cc" "none")
(set_attr "length" "2")])
Index: config/h8300/t-h8300
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/t-h8300,v
retrieving revision 1.8
diff -c -r1.8 t-h8300
*** config/h8300/t-h8300 30 Aug 2001 17:51:04 -0000 1.8
--- config/h8300/t-h8300 24 Sep 2002 14:28:59 -0000
***************
*** 25,33 ****
echo '#endif' >> fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
! MULTILIB_OPTIONS = mh/ms mint32
! MULTILIB_DIRNAMES = h8300h h8300s int32
! MULTILIB_EXCEPTIONS = mint32
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
--- 25,33 ----
echo '#endif' >> fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
! MULTILIB_OPTIONS = mh/ms mn mint32
! MULTILIB_DIRNAMES = h8300h h8300s normal int32
! MULTILIB_EXCEPTIONS = mint32 mn mn/mint32
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.188
diff -c -r1.188 invoke.texi
*** doc/invoke.texi 23 Sep 2002 15:00:42 -0000 1.188
--- doc/invoke.texi 24 Sep 2002 14:28:53 -0000
***************
*** 543,549 ****
@emph{H8/300 Options}
@gccoptlist{
! -mrelax -mh -ms -mint32 -malign-300}
@emph{SH Options}
@gccoptlist{
--- 543,549 ----
@emph{H8/300 Options}
@gccoptlist{
! -mrelax -mh -ms -mn -mint32 -malign-300}
@emph{SH Options}
@gccoptlist{
***************
*** 8413,8418 ****
--- 8413,8423 ----
@item -ms
@opindex ms
Generate code for the H8S@.
+
+ @item -mn
+ @opindex mn
+ Generate code for the H8S and H8/300H in Normal mode. This switch
+ must be used either with -mh or -ms.
@item -ms2600
@opindex ms2600