[patch] h8300.*: Add -ms2600 switch.
Kazu Hirata
kazu@hxi.com
Fri Aug 11 16:32:00 GMT 2000
Hi,
The H8/S2600 has a MAC register and relevant instructions whereas the
H8/S2000 does not. However, gcc generates mac instruction regardless;
it just has one switch, -ms.
The attached patch addresses this issue by adding a new switch,
-ms2600. The meaning of -ms is slightly changed in that, with -ms,
you can no longer generate the mac stuff. Other than that, -ms and
-ms2600 are exactly the same.
I checked the existing libraries (libc, libm, and libg). None of the
H8/S stuff contained use of mac reg/insn. I am wondering whether I
shuold do a separate build for those libraries. For your information,
the library tree currently looks like this. Yes, lots of variants.
/usr/local/h8300-hms/lib/libg.a
/usr/local/h8300-hms/lib/libm.a
/usr/local/h8300-hms/lib/libc.a
/usr/local/h8300-hms/lib/h8300h/libm.a
/usr/local/h8300-hms/lib/h8300h/libc.a
/usr/local/h8300-hms/lib/h8300h/libg.a
/usr/local/h8300-hms/lib/h8300h/int32/libm.a
/usr/local/h8300-hms/lib/h8300h/int32/libc.a
/usr/local/h8300-hms/lib/h8300h/int32/libg.a
/usr/local/h8300-hms/lib/h8300h/int32/libiberty.a
/usr/local/h8300-hms/lib/h8300h/libiberty.a
/usr/local/h8300-hms/lib/h8300s/libm.a
/usr/local/h8300-hms/lib/h8300s/libc.a
/usr/local/h8300-hms/lib/h8300s/libg.a
/usr/local/h8300-hms/lib/h8300s/int32/libm.a
/usr/local/h8300-hms/lib/h8300s/int32/libc.a
/usr/local/h8300-hms/lib/h8300s/int32/libg.a
/usr/local/h8300-hms/lib/h8300s/int32/libiberty.a
/usr/local/h8300-hms/lib/h8300s/libiberty.a
/usr/local/h8300-hms/lib/libiberty.a
Here is a code sample.
/* h8300-hms-gcc -ms -Wall -O2 -fomit-frame-pointer */
short
inner_product (short *a, short *b)
{
int i;
short sum = 0;
for (i = 9; i >= 0; i--)
sum += (*a++) * (*b++);
return sum;
}
/* gcc -ms generates:
_inner_product:
stm.l er4-er5,@-sp
sub.w r5,r5
mov.w #9,r4
.L6:
mov.w @er0+,r2
mov.w @er1+,r3
mulxs.w r3,er2
add.w r2,r5
dec.w #1,r4
bge .L6
mov.w r5,r0
ldm.l @sp+,er4-er5
rts
*/
/* gcc -ms2600 generates:
_inner_product:
push.l er4
sub.w r4,r4
mov.w #9,r3
.L6:
clrmac
mac @er1+,@er0+
stmac macl,er2
add.w r2,r4
dec.w #1,r3
bge .L6
mov.w r4,r0
pop.l er4
rts
*/
Thanks,
Kazu Hirata
===File ~/gnu/gcc/ChangeLog-h8300-mac=======================
2000-08-11 Kazu Hirata <kazu@hxi.com>
* invoke.texi (H8/300 Options): Add -ms2600.
* config/h8300.h
(CPP_SPEC): Support -ms2600.
(LINK_SPEC): Likewise.
(TARGET_H8300): Treat the H8/S2600 just like the H8/S2000.
(TARGET_SWITCHES): Add -ms2600 and -mno-s2600.
(CONDITIONA_REGISTER_USAGE): Disable the mac register on any
machine other than H8/S2600.
* config/h8300.md: Accept mac instructions on the H8/S2600 instead
of the H8/S2000.
============================================================
===File ~/gnu/gcc/h8300-mac.patch===========================
Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/invoke.texi,v
retrieving revision 1.210
diff -u -r1.210 invoke.texi
--- invoke.texi 2000/08/10 15:21:18 1.210
+++ invoke.texi 2000/08/11 21:50:07
@@ -6626,7 +6626,10 @@
Generate code for the H8/300H.
@item -ms
-Generate code for the H8/S.
+Generate code for the H8/S2000.
+
+@item -ms2600
+Generate code for the H8/S2600.
@item -mint32
Make @code{int} data 32 bits by default.
Index: config/h8300/h8300.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/h8300/h8300.h,v
retrieving revision 1.30
diff -u -r1.30 h8300.h
--- h8300.h 2000/08/08 23:09:52 1.30
+++ h8300.h 2000/08/11 21:50:08
@@ -40,16 +40,21 @@
"-D__LONG_MAX__=2147483647L -D__LONG_LONG_MAX__=2147483647L"
#define CPP_SPEC \
- "%{!mh:%{!ms:-D__H8300__}} %{mh:-D__H8300H__} %{ms:-D__H8300S__} \
- %{!mh:%{!ms:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}} \
+ "%{!mh:%{!ms:%{!ms2600:-D__H8300__}}} \
+ %{mh:-D__H8300H__} \
+ %{ms:-D__H8300S__} \
+ %{ms2600:-D__H8300S__} \
+ %{!mh:%{!ms:%{!ms2600:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int}}} \
%{mh:-D__SIZE_TYPE__=unsigned\\ long -D__PTRDIFF_TYPE__=long} \
%{ms:-D__SIZE_TYPE__=unsigned\\ long -D__PTRDIFF_TYPE__=long} \
- %{!mh:%{!ms:-Acpu(h8300) -Amachine(h8300)}} \
+ %{ms2600:-D__SIZE_TYPE__=unsigned\\ long -D__PTRDIFF_TYPE__=long} \
+ %{!mh:%{!ms:%{!ms2600:-Acpu(h8300) -Amachine(h8300)}}} \
%{mh:-Acpu(h8300h) -Amachine(h8300h)} \
%{ms:-Acpu(h8300s) -Amachine(h8300s)} \
+ %{ms2600:-Acpu(h8300s) -Amachine(h8300s)} \
%{!mint32:-D__INT_MAX__=32767} %{mint32:-D__INT_MAX__=2147483647}"
-#define LINK_SPEC "%{mh:-m h8300h} %{ms:-m h8300s}"
+#define LINK_SPEC "%{mh:-m h8300h} %{ms:-m h8300s} %{ms2600:-m h8300s}"
#define LIB_SPEC "%{mrelax:-relax} %{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
@@ -83,8 +88,11 @@
/* Select between the h8/300 and h8/300h cpus. */
#define TARGET_H8300 (! TARGET_H8300H && ! TARGET_H8300S)
#define TARGET_H8300H (target_flags & 4096)
-#define TARGET_H8300S (target_flags & 1)
+#define TARGET_H8300S ((target_flags & 1) || (target_flags & 2))
+/* mac register and relevant instructions are available. */
+#define TARGET_MAC (target_flags & 2)
+
/* 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.
@@ -99,8 +107,10 @@
An empty string NAME is used to identify the default VALUE. */
#define TARGET_SWITCHES \
- { {"s", 1, N_("Generate H8/S code")}, \
- {"no-s", -1, N_("Do not generate H8/S code")}, \
+ { {"s", 1, N_("Generate H8/S2000 code")}, \
+ {"no-s", -1, N_("Do not generate H8/S2000 code")}, \
+ {"s2600", 2, N_("Generate H8/S2600 code")}, \
+ {"no-s2600", -2, N_("Do not generate H8/S2600 code")}, \
{"int32", 8, N_("Make integers 32 bits wide")}, \
{"addresses", 64, NULL}, \
{"quickcall", 128, \
@@ -275,10 +285,10 @@
#define REG_ALLOC_ORDER \
{ 2, 3, 0, 1, 4, 5, 6, 8, 7, 9}
-#define CONDITIONAL_REGISTER_USAGE \
-{ \
- if (!TARGET_H8300S) \
- fixed_regs[8] = call_used_regs[8] = 1;\
+#define CONDITIONAL_REGISTER_USAGE \
+{ \
+ if (!TARGET_MAC) \
+ fixed_regs[8] = call_used_regs[8] = 1; \
}
/* Return number of consecutive hard regs needed starting at reg REGNO
Index: config/h8300/h8300.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/h8300/h8300.md,v
retrieving revision 1.16
diff -u -r1.16 h8300.md
--- h8300.md 2000/08/11 01:43:47 1.16
+++ h8300.md 2000/08/11 21:50:09
@@ -819,7 +819,7 @@
(mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
(sign_extend:SI
(mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
- "TARGET_H8300S"
+ "TARGET_MAC"
"clrmac\;mac @%2+,@%1+"
[(set_attr "length" "6")
(set_attr "cc" "none_0hit")])
@@ -832,7 +832,7 @@
(sign_extend:SI (mem:HI
(post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
(match_operand:SI 3 "register_operand" "0")))]
- "TARGET_H8300S"
+ "TARGET_MAC"
"mac @%2+,@%1+"
[(set_attr "length" "4")
(set_attr "cc" "none_0hit")])
============================================================
More information about the Gcc-patches
mailing list