changeset 672:3f559c67bc86

*** empty log message ***
author kono
date Sat, 05 May 2007 03:39:29 +0900
parents 85e0509832f1
children 442e90958386
files Changes Makefile.powerpc README.jp mc-code-ia32.c mc-code-powerpc.c mc-macro.c mc-parse.c
diffstat 7 files changed, 388 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Thu May 03 09:08:24 2007 +0900
+++ b/Changes	Sat May 05 03:39:29 2007 +0900
@@ -9232,3 +9232,30 @@
 まぁ、のりの問題だがな。
 
 64bit 対応をどうするんだろう?
+
+Fri May  4 20:07:59 JST 2007
+
+なるほど。PS3 だと、register に乗った引数の分は、スタックが
+取られてない。だから、bl regsiter_save する前に、stack を
+移動する必要がある。
+
+Breakpoint 3, 0x1000068c in i50 ()
+(gdb) x/20x $r1
+0xff9e00f0:     0xff9e0320      0x10001280      0x00000008      0x00000009
+0xff9e0100:     0x0000000a      0x0000000b      0x0000000c      0x0000000d
+0xff9e0110:     0x0000000e      0x0000000f      0x00000010      0x00000011
+0xff9e0120:     0x00000012      0x00000013      0x00000014      0x00000015
+0xff9e0130:     0x00000016      0x00000017      0x00000018      0x00000019
+(gdb) q
+
+そうすると、浮動小数点の場合は...
+
+Sat May  5 03:32:27 JST 2007
+
+
+dofor で、docomp で、RC を読んだときに、{...} k++; で、k を
+既に読んでしまっている。その後に、leave_scope しても、current nptr
+は、update されない。なので、leave_scope 中で、nptr を書き換える必要がある。
+
+
+
--- a/Makefile.powerpc	Thu May 03 09:08:24 2007 +0900
+++ b/Makefile.powerpc	Sat May 05 03:39:29 2007 +0900
@@ -1,12 +1,12 @@
 CC = gcc -std=c99
 #  -O2
 #  -O99
-CFLAGS = -g -Wall -I. -DUSE_CODE_KEYWORD
+CFLAGS = -fsigned-char -g -Wall -I. -DUSE_CODE_KEYWORD
 # CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
 # LDFLAGS = -pg
 # for Linux Zaurus
 # CFLAGS = -fsigned-char -pipe -g -I. -I/home/zaurus/develop/include
-CFLAGS1 = -g  -I. -DUSE_CODE_KEYWORD
+CFLAGS1 = -fsigned-char -g  -I. -DUSE_CODE_KEYWORD
 BASE=0
 STAGE=1
 MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE)
@@ -262,61 +262,177 @@
 
 # DO NOT DELETE
 
-mc-code-ia32.o: /usr/include/stdio.h /usr/include/_types.h
-mc-code-ia32.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-code-ia32.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-code-ia32.o: mc-parse.h mc-codegen.h mc-code.h mc-include.c
-mc-codegen.o: /usr/include/stdio.h /usr/include/_types.h
-mc-codegen.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-codegen.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-codegen.o: mc-parse.h mc-codegen.h mc-code.h mc-switch.h mc-inline.h
+mc-code-ia32.o: /usr/include/stdio.h /usr/include/features.h
+mc-code-ia32.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-code-ia32.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-code-ia32.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-code-ia32.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-code-ia32.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-code-ia32.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-code-ia32.o: /usr/include/gconv.h
+mc-code-ia32.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-code-ia32.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-code-ia32.o: /usr/include/bits/sys_errlist.h
+mc-code-ia32.o: /usr/include/bits/stdio-ldbl.h mc.h mc-parse.h mc-codegen.h
+mc-code-ia32.o: mc-code.h mc-include.c
+mc-codegen.o: /usr/include/stdio.h /usr/include/features.h
+mc-codegen.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-codegen.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-codegen.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-codegen.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-codegen.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-codegen.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-codegen.o: /usr/include/gconv.h
+mc-codegen.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-codegen.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-codegen.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+mc-codegen.o: mc.h mc-parse.h mc-codegen.h mc-code.h mc-switch.h mc-inline.h
 mc-codegen.o: conv/conv.h
-mc-parse.o: /usr/include/stdio.h /usr/include/_types.h
-mc-parse.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-parse.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-parse.o: mc-parse.h mc-codegen.h mc-switch.h mc-macro.h mc-inline.h
+mc-parse.o: /usr/include/stdio.h /usr/include/features.h
+mc-parse.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-parse.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-parse.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-parse.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-parse.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-parse.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-parse.o: /usr/include/gconv.h
+mc-parse.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-parse.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-parse.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+mc-parse.o: mc.h mc-parse.h mc-codegen.h mc-switch.h mc-macro.h mc-inline.h
 mc-parse.o: conv/conv.h
-mc-tree.o: /usr/include/stdio.h /usr/include/_types.h
-mc-tree.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-tree.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-tree.o: mc-parse.h mc-codegen.h
-mc-switch.o: /usr/include/stdio.h /usr/include/_types.h
-mc-switch.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-switch.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-switch.o: mc-parse.h mc-codegen.h mc-code.h
-mc-inline.o: /usr/include/stdio.h /usr/include/_types.h
-mc-inline.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-inline.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-inline.o: mc-parse.h mc-codegen.h mc-switch.h mc-code.h mc-inline.h
-mc-macro.o: /usr/include/stdio.h /usr/include/_types.h
-mc-macro.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-macro.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-macro.o: mc-parse.h mc-macro.h mc-codegen.h mc-code.h
-conv/c.o: /usr/include/stdio.h /usr/include/_types.h
-conv/c.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-conv/c.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+mc-tree.o: /usr/include/stdio.h /usr/include/features.h
+mc-tree.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-tree.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-tree.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-tree.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-tree.o: /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h
+mc-tree.o: /usr/include/bits/wchar.h /usr/include/gconv.h
+mc-tree.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-tree.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-tree.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+mc-tree.o: mc.h mc-parse.h mc-codegen.h
+mc-switch.o: /usr/include/stdio.h /usr/include/features.h
+mc-switch.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-switch.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-switch.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-switch.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-switch.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-switch.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-switch.o: /usr/include/gconv.h
+mc-switch.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-switch.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-switch.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+mc-switch.o: mc.h mc-parse.h mc-codegen.h mc-code.h
+mc-inline.o: /usr/include/stdio.h /usr/include/features.h
+mc-inline.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-inline.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-inline.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-inline.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-inline.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-inline.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-inline.o: /usr/include/gconv.h
+mc-inline.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-inline.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-inline.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+mc-inline.o: mc.h mc-parse.h mc-codegen.h mc-switch.h mc-code.h mc-inline.h
+mc-macro.o: /usr/include/stdio.h /usr/include/features.h
+mc-macro.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-macro.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-macro.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-macro.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-macro.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-macro.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-macro.o: /usr/include/gconv.h
+mc-macro.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-macro.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-macro.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+mc-macro.o: mc.h mc-parse.h mc-macro.h mc-codegen.h mc-code.h
+conv/c.o: /usr/include/stdio.h /usr/include/features.h
+conv/c.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+conv/c.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+conv/c.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+conv/c.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+conv/c.o: /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h
+conv/c.o: /usr/include/bits/wchar.h /usr/include/gconv.h
+conv/c.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+conv/c.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+conv/c.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h mc.h
 conv/c.o: mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h conv/c.h
-conv/c2cbc.o: /usr/include/stdio.h /usr/include/_types.h
-conv/c2cbc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-conv/c2cbc.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-conv/c2cbc.o: mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h conv/c2cbc.h
-conv/cbc2c.o: /usr/include/stdio.h /usr/include/_types.h
-conv/cbc2c.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-conv/cbc2c.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-conv/cbc2c.o: mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h conv/cbc2c.h
-conv/null.o: /usr/include/stdio.h /usr/include/_types.h
-conv/null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-conv/null.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-conv/null.o: mc-parse.h conv/conv.h conv/convdef.h conv/null.h
-mc-code-arm.o: /usr/include/stdio.h /usr/include/_types.h
-mc-code-arm.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-code-arm.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-code-arm.o: mc-parse.h mc-code.h mc-codegen.h
-mc-code-powerpc.o: /usr/include/stdio.h /usr/include/_types.h
-mc-code-powerpc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-code-powerpc.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h
-mc-code-powerpc.o: mc.h mc-parse.h mc-code.h mc-codegen.h mc-include.c
-mc-code-mips.o: /usr/include/stdio.h /usr/include/_types.h
-mc-code-mips.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
-mc-code-mips.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
-mc-code-mips.o: mc-parse.h mc-code.h mc-codegen.h
+conv/c2cbc.o: /usr/include/stdio.h /usr/include/features.h
+conv/c2cbc.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+conv/c2cbc.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+conv/c2cbc.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+conv/c2cbc.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+conv/c2cbc.o: /usr/include/libio.h /usr/include/_G_config.h
+conv/c2cbc.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+conv/c2cbc.o: /usr/include/gconv.h
+conv/c2cbc.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+conv/c2cbc.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+conv/c2cbc.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+conv/c2cbc.o: mc.h mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h
+conv/c2cbc.o: conv/c2cbc.h
+conv/cbc2c.o: /usr/include/stdio.h /usr/include/features.h
+conv/cbc2c.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+conv/cbc2c.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+conv/cbc2c.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+conv/cbc2c.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+conv/cbc2c.o: /usr/include/libio.h /usr/include/_G_config.h
+conv/cbc2c.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+conv/cbc2c.o: /usr/include/gconv.h
+conv/cbc2c.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+conv/cbc2c.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+conv/cbc2c.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+conv/cbc2c.o: mc.h mc-parse.h mc-codegen.h conv/conv.h conv/convdef.h
+conv/cbc2c.o: conv/cbc2c.h
+conv/null.o: /usr/include/stdio.h /usr/include/features.h
+conv/null.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+conv/null.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+conv/null.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+conv/null.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+conv/null.o: /usr/include/libio.h /usr/include/_G_config.h
+conv/null.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+conv/null.o: /usr/include/gconv.h
+conv/null.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+conv/null.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+conv/null.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+conv/null.o: mc.h mc-parse.h conv/conv.h conv/convdef.h conv/null.h
+mc-code-arm.o: /usr/include/stdio.h /usr/include/features.h
+mc-code-arm.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-code-arm.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-code-arm.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-code-arm.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-code-arm.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-code-arm.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-code-arm.o: /usr/include/gconv.h
+mc-code-arm.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-code-arm.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-code-arm.o: /usr/include/bits/sys_errlist.h /usr/include/bits/stdio-ldbl.h
+mc-code-arm.o: mc.h mc-parse.h mc-code.h mc-codegen.h
+mc-code-powerpc.o: /usr/include/stdio.h /usr/include/features.h
+mc-code-powerpc.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-code-powerpc.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-code-powerpc.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-code-powerpc.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-code-powerpc.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-code-powerpc.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-code-powerpc.o: /usr/include/gconv.h
+mc-code-powerpc.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-code-powerpc.o: /usr/include/bits/libio-ldbl.h
+mc-code-powerpc.o: /usr/include/bits/stdio_lim.h
+mc-code-powerpc.o: /usr/include/bits/sys_errlist.h
+mc-code-powerpc.o: /usr/include/bits/stdio-ldbl.h mc.h mc-parse.h mc-code.h
+mc-code-powerpc.o: mc-codegen.h mc-include.c
+mc-code-mips.o: /usr/include/stdio.h /usr/include/features.h
+mc-code-mips.o: /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h
+mc-code-mips.o: /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h
+mc-code-mips.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stddef.h
+mc-code-mips.o: /usr/include/bits/types.h /usr/include/bits/typesizes.h
+mc-code-mips.o: /usr/include/libio.h /usr/include/_G_config.h
+mc-code-mips.o: /usr/include/wchar.h /usr/include/bits/wchar.h
+mc-code-mips.o: /usr/include/gconv.h
+mc-code-mips.o: /usr/lib/gcc/ppc64-redhat-linux/4.1.0/include/stdarg.h
+mc-code-mips.o: /usr/include/bits/libio-ldbl.h /usr/include/bits/stdio_lim.h
+mc-code-mips.o: /usr/include/bits/sys_errlist.h
+mc-code-mips.o: /usr/include/bits/stdio-ldbl.h mc.h mc-parse.h mc-code.h
+mc-code-mips.o: mc-codegen.h mc-include.c
--- a/README.jp	Thu May 03 09:08:24 2007 +0900
+++ b/README.jp	Sat May 05 03:39:29 2007 +0900
@@ -1,5 +1,4 @@
 C with Continuation (CwC) and Continuation based C (CbC)
-    $Id$
              河野 真治 
              琉球大学情報工学科
 
--- a/mc-code-ia32.c	Thu May 03 09:08:24 2007 +0900
+++ b/mc-code-ia32.c	Sat May 05 03:39:29 2007 +0900
@@ -136,7 +136,7 @@
 #define __LDBL_DIG__ 18\n\
 #define __i386 1\n\
 #define __FLT_MANT_DIG__ 24\n\
-#define __VERSION__ \"micro-c $Id$\"\n\
+#define __VERSION__ \"micro-c mc-code-ia32.c kono Exp $\"\n\
 #define i386 1\n\
 #define __i486__ 1\n\
 #define unix 1\n\
--- a/mc-code-powerpc.c	Thu May 03 09:08:24 2007 +0900
+++ b/mc-code-powerpc.c	Sat May 05 03:39:29 2007 +0900
@@ -183,6 +183,9 @@
 static int r1_offset_label;
 static int lvar_offset_label;
 static int max_func_arg_label;
+#ifndef __APPLE__
+static int arg_offset_label;
+#endif
 
 static int reg_save;
 static int freg_save;
@@ -438,15 +441,27 @@
      f1-r8  input register
      f24-f31 saved register variable
 
- function call stack frame
+ function call stack frame (Mac OS X)
                       <-------r1_offset------------------------------>
+                                     r30
                                       <------------lvar_offset0------>
-                      <--lvar_offset-->          r30(?)              r1
+                      <--lvar_offset-->                              r1
  r+  +------------+---+---------------+----------+--------------+----+    -
       callee arg   xx   register save   local      caller arg     xx
                           reg_save      disp       max_func_args*SIZE_OF_INT
         lvar>0                         lvar<0       lvar>0x1000 0000
 
+ function call stack frame (PS3)
+              <---------------r1_offset------------------------------>
+                                      r30-->
+                       <--arg_offset-->
+              <----------lvar_offset-->                         <----r1
+ r+  +------+-+--------+---------------+----------+--------------+----+    -
+  callee arg   reg arg register save   local      caller arg     xx
+                          reg_save      disp       max_func_args*SIZE_OF_INT
+        lvar>0                         lvar<0       lvar>0x1000 0000
+
+
 code segment stack frame
 
                  * gotoを呼び出した関数のr1 ! r1(goto前のr1)
@@ -466,14 +481,16 @@
 #define arg_offset1  24
 
 #define func_disp_offset 68
+#define func_disp_offset1 16
 #define code_disp_offset0 (0)
 
 #else
 
-#define arg_offset  (-24)
-#define arg_offset1  (-24)
-
-#define func_disp_offset (16)
+#define arg_offset  (8)
+#define arg_offset1  (8)
+
+#define func_disp_offset (8)
+#define func_disp_offset1 (16)
 #define code_disp_offset0 (0)
 
 #endif
@@ -483,8 +500,8 @@
 #define CODE_LVAR(l) ((l)+code_disp_offset0)
 #define CODE_CALLER_ARG(l) ((l)+arg_offset1)
 #define FUNC_LVAR(l) ((l)+disp_offset)
+#define CALLEE_ARG(l) ((l)+arg_offset)
 #define CALLER_ARG(l) ((l)+arg_offset1)
-#define CALLEE_ARG(l) ((l)+arg_offset)
 
 #define round16(a)    ((a+0xf)&~0xf)
 
@@ -495,8 +512,8 @@
     int l;
 #endif
     int lvar_offsetv = 
-	round16(-disp+max_func_args*SIZE_OF_INT+func_disp_offset);
-    int r1_offsetv = round16(lvar_offsetv-reg_save+16);
+	round16(-disp+max_func_args*SIZE_OF_INT)+func_disp_offset;
+    int r1_offsetv = round16(lvar_offsetv-reg_save)+func_disp_offset1;
 
     printf(".set %s%d,%d\n",lpfx,lvar_offset_label,r1_offsetv-lvar_offsetv);
     if (r1_offsetv-lvar_offsetv > 65000) error(-1);
@@ -631,7 +648,7 @@
 	} else if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
 	    printf("%d@l(1)\n",CALLER_ARG(l-ARG_LVAR_OFFSET));
 	} else { /* callee's arguments */
-	    printf("%d+%s%d@l(%d)\n",CALLEE_ARG(l),lpfx,lvar_offset_label,REG_fp);
+            printf("%d+%s%d@l(%d)\n",CALLEE_ARG(l),lpfx,lvar_offset_label,REG_fp) ;
 	}
     } else {
         rn = register_name(large_offset_reg);
@@ -692,7 +709,7 @@
         if (LARGE_OFFSET(CALLEE_ARG(l))) {
             rn=register_name(large_offset_reg=get_register());
             printf("\tla %s,%d,%d+%s%d@ha\n",
-		rn,REG_fp,CALLEE_ARG(l),lpfx,lvar_offset_label);
+                rn,REG_fp,CALLEE_ARG(l),lpfx,lvar_offset_label);
         }
     }
 }
@@ -760,6 +777,7 @@
     int i;
     int is_code0 = is_code(fnptr);
     int dots;
+    int arg_offset_v = 0;
 
     function_type(fnptr->ty,&dots);
     while (args) {
@@ -772,7 +790,7 @@
                 n->dsp = cadr(reg);
                 regs[n->dsp]= INPUT_REG;
                 reg_var++;
-                cadddr(args)=SIZE_OF_INT;
+		arg_offset_v += (cadddr(args)=SIZE_OF_INT);
             }
         } else if (type==FLOAT) {
             if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) {
@@ -780,7 +798,7 @@
                 n->dsp = cadr(reg);
                 regs[n->dsp]= INPUT_REG;
                 freg_var++;
-                cadddr(args)=size(type);
+		arg_offset_v += (cadddr(args)=size(type));
             }
         } else if (type==DOUBLE) {
             if ((reg = get_input_dregister_var(freg_var,n,is_code0,1))) {
@@ -788,7 +806,7 @@
                 n->dsp = cadr(reg);
                 regs[n->dsp]= INPUT_REG;
                 freg_var++;
-                cadddr(args)=size(type);
+		arg_offset_v += (cadddr(args)=size(type));
             }
         } else if (type==LONGLONG||type==ULONGLONG) {
             if ((reg = get_input_lregister_var(reg_var,n,is_code0))) {
@@ -798,13 +816,17 @@
                 regs[regv_l(i)]= INPUT_REG;
                 regs[regv_h(i)]= INPUT_REG;
                 reg_var+=2;
-                cadddr(args)=size(type);
+		arg_offset_v += (cadddr(args)=size(type));
             }
         }
         args = cadr(args);
     }
-    if (is_function(fnptr))
+    if (is_function(fnptr)) {
 	code_save_input_registers(dots);
+#ifndef __APPLE__
+	printf(".set %s%d, %d\n",lpfx, arg_offset_label,arg_offset_v);
+#endif
+    }
 }
 
 
@@ -1075,6 +1097,7 @@
 	} else {
 	    if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
 	    i = i+MIN_TMP_REG;
+            if (i%2==1) i++;
 	}
 	ll = get_lregister1(i,i+1);
 #if ENDIAN_L==0
@@ -2143,15 +2166,22 @@
 	    /* regs[reg]==INPUT_REG case should be considered */
 	    n->dsp = offset;
 	    t = n->ty;
+#ifdef __APPLE__
 	    if(t==FLOAT) { offset+=SIZE_OF_FLOAT; reg_offset+=1; }
 	    else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; reg_offset+=2; }
 	    else error(-1);
 	    reg_var += 2;
+#else
+	    if(t==FLOAT) { offset+=SIZE_OF_FLOAT;  }
+	    else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; }
+	    else error(-1);
+#endif
 	} else if (tag==LREGISTER) {
 	    /* regs[reg]==INPUT_REG case should be considered */
 	    n->dsp = offset;
 	    t = n->ty;
-	    offset+=SIZE_OF_LONGLONG; reg_offset+=2;
+	    offset+=SIZE_OF_LONGLONG; 
+	    reg_offset+=2;
 	    reg_var += 2;
 	} else {
 	    // n->dsp = offset;  this is no allowed becase of arg reorder
@@ -2295,16 +2325,19 @@
 	t = type_value(cadr(t));
     }
     if(scalar(t)) {
-	nargs ++ ; reg_arg++;
+	reg_arg++;
+	if (*preg_arg>=MAX_INPUT_REGISTER_VAR) nargs ++ ; 
     } else if (t==LONGLONG||t==ULONGLONG) {
-	nargs ++ ; reg_arg++;
-	nargs ++ ; reg_arg++;
+        if (*preg_arg%2==1) reg_arg++;  // alignment
+        if (*pnargs%2==1) nargs++;  // alignment
+	reg_arg++; reg_arg++;
+	if (*preg_arg+1>=MAX_INPUT_REGISTER_VAR)  nargs += 2;
     } else if (t==FLOAT) {
 	freg_arg++;
-	nargs += size(t)/SIZE_OF_INT;
+	if (*pfreg_arg>=MAX_INPUT_DREGISTER_VAR) nargs += size(t)/SIZE_OF_INT;
     } else if (t==DOUBLE) {
-	nargs += round4(size(t))/SIZE_OF_INT;
 	freg_arg++;
+	if (*pfreg_arg>=MAX_INPUT_DREGISTER_VAR) nargs += round4(size(t))/SIZE_OF_INT;
     } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
 	nargs += round4(size(t))/SIZE_OF_INT;
     } else {
@@ -2352,7 +2385,7 @@
 	if (mode==AS_SAVE) {
 	    return get_dregister_var(0,1);
 	} else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) {
-	    return list3(LVAR,caller_arg_offset_v(nargs)-36,0);
+	    return list3(LVAR,caller_arg_offset_v(nargs),0);
 	} else
 	    return get_input_dregister_var(freg_arg,0,0,1);
     } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
@@ -2626,16 +2659,28 @@
 {
     char *crn,*grn;
     int g;
-  
-    g_expr(list3(BAND,list3(ADD,e1,list2(CONST,30)),list2(CONST,~15))); 
+
+    if (!is_const(e1)) {
+        g_expr(list3(BAND,list3(ADD,e1,list2(CONST,15)),list2(CONST,~15))); 
+        use_int(reg);
+    } else {
+        use_int(reg);
+        code_const(round16(cadr(e1)),reg);
+    }
     use_int(reg);
     g = get_register();
     crn = register_name(reg);
     grn = register_name(g);
 //    printf("\trlwinm r0,%s,0,0,27\n",crn);
+#ifdef R1SAVE
     printf("\tlwz %s,0(%s)\n",grn,register_name(1));
     printf("\tneg %s,%s\n",crn,crn);
     printf("\tstwux %s,%s,%s\n",grn,register_name(1),crn);
+#else
+    printf("\tlwz %s,0(%s)\n",grn,register_name(1));
+    printf("\tneg %s,%s\n",crn,crn);
+    printf("\tstwux %s,%s,%s\n",grn,register_name(1),crn);
+#endif
 //    printf("\tstw %s,0(r1)\n",grn);
     if (!max_func_arg_label) max_func_arg_label = fwdlabel();
 #ifdef __APPLE__
@@ -3248,8 +3293,8 @@
 #if 0
     printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label);
 #else
-    printf("\tla r1,.LC%d@l(r30)\n",code_disp_label);
-    printf("\taddis r1,r1,.LC%d@ha\n",code_disp_label);
+    printf("\tla 1,%s%d@l(31)\n",lpfx,code_disp_label);
+    printf("\taddis 1,1,%s%d@ha\n",lpfx,code_disp_label);
 #endif
     max_func_args = 0;
     clear_ptr_cache();
@@ -3332,14 +3377,17 @@
  */
     printf("%s:\n",name);
     code_setup=fwdlabel();
+    arg_offset_label = fwdlabel();
     printf("\tmflr 0\n");
+    printf("\tstwu %d,-%s%d@l(%d)\n",1,lpfx,arg_offset_label,1);
     printf("\tbl .LC%d\n",code_setup);
     r1_offset_label = fwdlabel();
     lvar_offset_label = fwdlabel();
 
-    printf("\taddi %d,%d,-%s%d@l\n",REG_fp,1,lpfx,lvar_offset_label);
+    printf("\tmr %d,1\n",REG_fp);
+    printf("\taddi %d,1,-%s%d@l\n",REG_fp,lpfx,lvar_offset_label);
     printf("\tlis %d,-%s%d@ha\n",30,lpfx,r1_offset_label);
-    printf("\taddi %d,%d,-%s%d@l\n",30,REG_fp,lpfx,r1_offset_label);
+    printf("\taddi %d,%d,-%s%d@l\n",30,30,lpfx,r1_offset_label);
     printf("\tstwux 1,1,%d\n",30);
 #endif
     max_func_args = 0;
@@ -3399,11 +3447,13 @@
 " stfd    27,-40(1)",
 " stfd    28,-32(1)",
 " stfd    29,-24(1)",
-" stfd    30,-16(1)",
-" stfd    31,-8(1)",
+" stfd    31,-16(1)",
+" stfd    30,-8(1)",
 " stw     0,8(1)",
 " blr",
-".restFP:    lfd     14,-144(1)",
+".restFP:    ",
+" lwz     1,0(1)",
+" lfd     14,-144(1)",
 " lfd     15,-136(1)",
 " lfd     16,-128(1)",
 " lfd     17,-120(1)",
@@ -3419,9 +3469,11 @@
 " lfd     27,-40(1)",
 " lfd     28,-32(1)",
 " lfd     29,-24(1)",
-" lwz     0,8(1)",
-" lfd     30,-16(1)",
+" lwz     0,4(1)",
+" lfd     31,-16(1)",
+" lwz     1,0(1)",
 " mtlr    0",
+" blr",
 0
 };
 #endif
@@ -3482,7 +3534,7 @@
 #ifdef __APPLE__
     printf("\taddi r1,r30,lo16(L_%d)\n",lvar_offset_label);
 #else
-    printf("\taddi 1,%d,.LC%d@l\n",REG_fp,lvar_offset_label);
+    printf("\taddi 1,%d,%s%d@l\n",REG_fp,lpfx,lvar_offset_label);
 #endif
 #endif
     if (max_freg_var>=0) {
@@ -3508,19 +3560,26 @@
 	printf("\tlmw r%d,%d(r1)\n",
 		    REG_VAR_BASE-max_reg_var,reg_save);
 #else
-	printf("\tlwz %s,8(1)\n",register_name(0));
-	printf("\tmtlr %s\n",register_name(0));
 	printf("\tlmw %d,%d(1)\n",
 		    REG_VAR_BASE-max_reg_var,reg_save);
+	printf("\tlwz %s,4(1)\n",register_name(0));
+	printf("\tlwz 1,0(1)\n");
+	printf("\tmtlr %s\n",register_name(0));
 #endif
 	code_ret();
     }
 
     disp &= -SIZE_OF_INT;
     fwddef(code_setup);
+#ifdef __APPLE__
     printf("\tstmw %s,%d(%s)\n",
 		    register_name(REG_VAR_BASE-max_reg_var),reg_save,register_name(1));
     printf("\tstw %s,8(%s)\n",register_name(0),register_name(1));
+#else
+    printf("\tstmw %s,%d(%s)\n",
+		    register_name(REG_VAR_BASE-max_reg_var),reg_save,register_name(1));
+    printf("\tstw %s,4(%s)\n",register_name(0),register_name(1));
+#endif
     if (max_freg_var>=0) {
 #ifdef __APPLE__
 	printf("\tb saveFP+%d ; save f%d-f31\n",
@@ -5113,7 +5172,7 @@
 #ifdef __APPLE__
 ".text",
 "        .align 2",
-"lsrd__:",
+".lsrd__:",
 "       mr.     r5,r5",
 "       beqlr",
 "       subfic  r2,r5,32",
@@ -5141,7 +5200,30 @@
 #else
 ".text",
 "        .align 2",
-"lsrd__:",
+".lsrd__:",
+"       mr.     5,5",
+"       beqlr",
+"       subfic  2,5,32",
+"      stw     3,-32(1)",
+"      stw     4,-28(1)",
+"      cmpwi   7,2,0",
+"      bgt+    7,.L__lsrd1",
+"      neg     0,2",
+"      lwz     2,-32(1)",
+"      li      9,0",
+"      srw     2,2,0",
+"      stw     9,-48(1)",
+"      b       .L__lsrd2",
+".L__lsrd1:      lwz     0,-32(1)",
+"      slw     9,0,2",
+"      lwz     2,-28(1)",
+"      srw     0,0,5",
+"      srw     2,2,5",
+"      stw     0,-48(1)",
+"      or      2,2,9",
+".L__lsrd2:      stw     2,-44(1)",
+"      lwz     3,-48(1)",
+"      lwz     4,-44(1)",
 "      blr",
 #endif
 0
@@ -5152,7 +5234,7 @@
 #ifdef __APPLE__
 ".text",
 "        .align 2",
-"asld__:",
+".asld__:",
 "       mr.     r5,r5",
 "       beqlr",
 "       subfic  r2,r5,32",
@@ -5180,7 +5262,30 @@
 #else
 ".text",
 "        .align 2",
-"asld__:",
+".asld__:",
+"       mr.     5,5",
+"       beqlr",
+"       subfic  2,5,32",
+"      stw     3,-32(1)",
+"      stw     4,-28(1)",
+"      cmpwi   7,2,0",
+"      bgt+    7,.L__asld1",
+"      neg     0,2",
+"      lwz     2,-28(1)",
+"      li      9,0",
+"      slw     2,2,0",
+"      stw     9,-44(1)",
+"      b       .L__asld2",
+".L__asld1:      lwz     0,-28(1)",
+"      srw     9,0,2",
+"      lwz     2,-32(1)",
+"      slw     0,0,5",
+"      slw     2,2,5",
+"      stw     0,-44(1)",
+"      or      2,2,9",
+".L__asld2:      stw     2,-48(1)",
+"      lwz     3,-48(1)",
+"      lwz     4,-44(1)",
 "      blr",
 #endif
 0
@@ -5191,7 +5296,7 @@
 #ifdef __APPLE__
 ".text",
 "        .align 2",
-"asrd__:",
+".asrd__:",
 "       mr.     r5,r5",
 "       beqlr",
 "       subfic  r2,r5,32",
@@ -5218,7 +5323,30 @@
 #else
 ".text",
 "        .align 2",
-"asrd__:",
+".asrd__:",
+"       mr.     5,5",
+"       beqlr",
+"       subfic  2,5,32",
+"      stw     3,-32(1)",
+"      stw     4,-28(1)",
+"      cmpwi   7,2,0",
+"      bgt+    7,.L__asrd1",
+"      lwz     0,-32(1)",
+"      neg     2,2",
+"      sraw    2,0,2",
+"      srawi   0,0,31",
+"      b       .L__asrd2",
+".L__asrd1:      lwz     0,-32(1)",
+"      slw     9,0,2",
+"      lwz     2,-28(1)",
+"      sraw    0,0,5",
+"      srw     2,2,5",
+"      or      2,2,9",
+".L__asrd2:      stw     0,-48(1)",
+"      stw     2,-44(1)",
+"      lwz     3,-48(1)",
+"      lwz     4,-44(1)",
+"      blr",
 #endif
 0
 };
@@ -5280,7 +5408,7 @@
 	    register_name(5),
 	    lregister_name_low(oreg));
     }
-    printf("\tbl asld__\n");
+    printf("\tbl .asld__\n");
 }
 
 static void
@@ -5296,7 +5424,7 @@
 	    register_name(5),
 	    lregister_name_low(oreg));
     }
-    printf("\tbl asrd__\n");
+    printf("\tbl .asrd__\n");
 }
 
 static void
@@ -5312,7 +5440,7 @@
 	    register_name(5),
 	    lregister_name_low(oreg));
     }
-    printf("\tbl lsrd__\n");
+    printf("\tbl .lsrd__\n");
 }
 
 static void
@@ -6035,10 +6163,8 @@
     printf("\tmtctr r0\n");
     printf("\tbctr\n");
 #else
-    printf("\taddis %s,31,%s%d@h\n",
-	     srn,lpfx,l);
-    printf("\tla %s,%s%d@l(%s)\n",
-	     srn,lpfx,l,srn);
+    printf("\tlis %s,%s%d@ha\n",srn,lpfx,l);
+    printf("\tla %s,%s%d@l(%s)\n",srn,lpfx,l,srn);
     printf("\tadd %s,%s,%s\n",trn,srn,trn);
     printf("\tlwz 0,0(%s)\n",trn);
     printf("\tadd 0,0,%s\n",srn);
--- a/mc-macro.c	Thu May 03 09:08:24 2007 +0900
+++ b/mc-macro.c	Sat May 05 03:39:29 2007 +0900
@@ -209,7 +209,7 @@
 getfname(int next)
 {
     int i,end='"',err=0;
-    char *s,*p,**pp,*name,*prev=0;
+    char *s,*p=0,**pp,*name,*prev=0;
     FILE *fp;
     struct cheap scheap;
     name = cheap->ptr;
--- a/mc-parse.c	Thu May 03 09:08:24 2007 +0900
+++ b/mc-parse.c	Sat May 05 03:39:29 2007 +0900
@@ -4838,6 +4838,7 @@
 free_nptr(NMTBL *n)
 {
     n->dsp = (int)free_nptr_list;
+    n->sc = 0;
     free_nptr_list = n;
 }
 
@@ -4965,6 +4966,7 @@
 	    car(current_scope) = glist3(ns,car(current_scope),(int)nptr1);
 	    caddr(ns) = (int)(nptr1 = get_nptr());
 	    nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0;
+	    break;
 	}
     }
     return nptr1;
@@ -4982,6 +4984,7 @@
 	    car(scope) = glist3(ns,car(scope),(int)nptr1);
 	    caddr(ns) = (int)(nptr1 = get_nptr());
 	    nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0;
+	    break;
 	}
     } 
     return nptr1;
@@ -5005,7 +5008,13 @@
 	ns = (NMTBL *)caddr(car(scope));
 	switch(ns->sc) {
 	case GVAR: case STATIC: case IVAR: break;
-	default: if (!inmode) free_nptr(ns);
+	default: if (!inmode) {
+		if (sym==IDENT && ns==nptr) {
+		    // this is already read aheaded, replace it
+		    nptr = (NMTBL*)caddr(scope);
+		}
+		free_nptr(ns);
+	    }
 	}
 	caddr(car(scope)) = caddr(scope);
 	next = cadr(scope);