annotate mc-code-powerpc.c @ 908:0df95413f583

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 09 Apr 2014 11:44:01 +0900 (2014-04-09)
parents 8bdd5061cb8f
children 485f13206916
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1 /* Micro-C Code Generation Part for Power PC (Mac OS X) */
607
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
2
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
3 /*
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
4 ************************************************************************
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
5 ** Copyright (C) 2006 Shinji Kono
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
6 ** 連絡先: 琉球大学情報工学科 河野 真治
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
7 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
607
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
8 **
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
9 ** このソースのいかなる複写,改変,修正も許諾します。ただし、
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
10 ** その際には、誰が貢献したを示すこの部分を残すこと。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
11 ** 再配布や雑誌の付録などの問い合わせも必要ありません。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
12 ** 営利利用も上記に反しない範囲で許可します。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
13 ** バイナリの配布の際にはversion messageを保存することを条件とします。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
14 ** このプログラムについては特に何の保証もしない、悪しからず。
607
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
15 **
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
16 ** Everyone is permitted to do anything on this program
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
17 ** including copying, modifying, improving,
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
18 ** as long as you don't try to pretend that you wrote it.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
19 ** i.e., the above copyright notice has to appear in all copies.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
20 ** Binary distribution requires original version messages.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
21 ** You don't have to ask before copying, redistribution or publishing.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
22 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
23 ***********************************************************************
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
24 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
25
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
26 #include <stdio.h>
89
917947ffeb7c power pc version
kono
parents:
diff changeset
27 #include "mc.h"
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
28 #include "mc-parse.h"
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
29 #include "mc-code.h"
89
917947ffeb7c power pc version
kono
parents:
diff changeset
30 #include "mc-codegen.h"
917947ffeb7c power pc version
kono
parents:
diff changeset
31
615
2dee957ef988 test case on undeclared name
kono
parents: 612
diff changeset
32 #include "mc-include.c"
324
575481408653 minor fix
kono
parents: 320
diff changeset
33
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 663
diff changeset
34 // #undef __APPLE__
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
35
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
36 static
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
37 char *init_src0 =
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
38 #ifdef __APPLE__
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
39 "\
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
40 #define __ppc__ 1\n\
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
41 #define __BIG_ENDIAN__ 1\n\
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
42 #define __STDC__ 1\n\
469
cf1c2c42b7c8 fix iassop
kono
parents: 468
diff changeset
43 #define __GNUC__ 1\n\
526
9ff5cd7afe2f *** empty log message ***
kono
parents: 518
diff changeset
44 #define __inline inline\n\
9ff5cd7afe2f *** empty log message ***
kono
parents: 518
diff changeset
45 #define __inline__ inline\n\
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
46 #define __builtin_va_list int\n\
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
47 #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
48 #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
49 #define alloca __builtin_alloca\n\
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
50 #define __FLT_MIN__ 1.17549435e-38F\n\
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
51 #define __DBL_MIN__ 2.2250738585072014e-308\n\
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
52 #define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L\n\
636
72c4a8137fff String concatenation fix
kono
parents: 616
diff changeset
53 "
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
54 #else
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
55 "\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
56 #define __inline inline\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
57 #define __extension__\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
58 #define __const const\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
59 #define __inline__ inline\n\
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
60 typedef struct __builtin_va_list { \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
61 long long_last; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
62 long float_first; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
63 long float_last; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
64 long stack_top; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
65 long arg; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
66 long top; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
67 } __builtin_va_list; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
68 \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
69 #define __builtin_va_start(__ap0,v) \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
70 { \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
71 __builtin_va_list *__ap = &__ap0; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
72 long __top = __ap->top = (long)&__my_va_list; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
73 __ap->long_last = __top +32; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
74 __ap->float_first = __ap->long_last; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
75 __ap->stack_top = __top+32+64+8; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
76 long __adr = (long)(&v) + sizeof(v); \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
77 if (__adr >= __ap->stack_top) __ap->arg = __ap->float_first = __adr; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
78 if (__builtin_types_compatible_p(typeof(v),double)) \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
79 __ap->float_first = __adr; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
80 __ap->arg = __adr; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
81 } \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
82 \n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
83 #define __builtin_va_arg(__ap0,type) ({ \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
84 __builtin_va_list *__ap = &__ap0; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
85 long __arg; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
86 if (__builtin_types_compatible_p(type,double) \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
87 && __ap->float_first < __ap->stack_top) { \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
88 __arg = __ap->float_first; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
89 __ap->float_first = __ap->float_first+8; \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
90 if (__ap->float_first==__ap->float_last) \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
91 __ap->float_first = __ap->stack_top;\\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
92 } else { \\\n\
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
93 if (__builtin_types_compatible_p(type,long long)) { \\\n\
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
94 if (__ap->arg==__ap->top+4) __ap->arg += 4; \\\n\
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
95 __arg = __ap->arg; \\\n\
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
96 __ap->arg += 8; \\\n\
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
97 if (__ap->arg==__ap->top+16+16) \\\n\
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
98 __ap->arg = __ap->stack_top; \\\n\
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
99 } else { \\\n\
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
100 __arg = __ap->arg; \\\n\
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
101 __ap->arg = __ap->arg+sizeof(type); \\\n\
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
102 if (__ap->arg==__ap->long_last) \\\n\
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
103 __ap->arg = __ap->stack_top; \\\n\
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
104 } \\\n\
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
105 } \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
106 *((type *)(__arg)); \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
107 }) \\\n\
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
108 \n"
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
109
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
110 "// #define __builtin_va_arg(ap,type) (*((type *)__builtin_va_next((type),&ap)))\n\
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
111 #define alloca __builtin_alloca\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
112 #define __DBL_MIN_EXP__ (-1021)\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
113 #define __FLT_MIN__ 1.17549435e-38F\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
114 #define __CHAR_BIT__ 8\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
115 #define __WCHAR_MAX__ 2147483647\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
116 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
117 #define __FLT_EVAL_METHOD__ 0\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
118 #define __DBL_MIN_10_EXP__ (-307)\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
119 #define __FINITE_MATH_ONLY__ 0\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
120 #define __GNUC_PATCHLEVEL__ 0\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
121 #define __SHRT_MAX__ 32767\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
122 #define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
123 #define __UINTMAX_TYPE__ long long unsigned int\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
124 #define __linux 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
125 #define __CHAR_UNSIGNED__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
126 #define __LDBL_MAX_EXP__ 1024\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
127 #define __linux__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
128 #define __SCHAR_MAX__ 127\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
129 #define __USER_LABEL_PREFIX__ \n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
130 #define __STDC_HOSTED__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
131 #define __LDBL_HAS_INFINITY__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
132 #define __DBL_DIG__ 15\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
133 #define __FLT_EPSILON__ 1.19209290e-7F\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
134 #define _CALL_SYSV 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
135 #define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
136 #define __unix__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
137 #define __DECIMAL_DIG__ 33\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
138 #define __gnu_linux__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
139 #define __LDBL_HAS_QUIET_NAN__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
140 #define __GNUC__ 4\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
141 #define __DBL_MAX__ 1.7976931348623157e+308\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
142 #define __DBL_HAS_INFINITY__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
143 #define __DBL_MAX_EXP__ 1024\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
144 #define __LONG_LONG_MAX__ 9223372036854775807LL\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
145 #define __PPC__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
146 #define __GXX_ABI_VERSION 1002\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
147 #define __FLT_MIN_EXP__ (-125)\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
148 #define __DBL_MIN__ 2.2250738585072014e-308\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
149 #define __DBL_HAS_QUIET_NAN__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
150 #define __REGISTER_PREFIX__ \n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
151 #define __NO_INLINE__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
152 #define _ARCH_PPC 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
153 #define __FLT_MANT_DIG__ 24\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
154 #define __VERSION__ \"mc-powerpc\"\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
155 #define __BIG_ENDIAN__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
156 #define __powerpc__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
157 #define unix 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
158 #define __SIZE_TYPE__ unsigned int\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
159 #define __ELF__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
160 #define __FLT_RADIX__ 2\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
161 #define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
162 #define __GNUC_RH_RELEASE__ 3\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
163 #define __LDBL_DIG__ 31\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
164 #define __FLT_HAS_QUIET_NAN__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
165 #define __FLT_MAX_10_EXP__ 38\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
166 #define __LONG_MAX__ 2147483647L\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
167 #define __FLT_HAS_INFINITY__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
168 #define __unix 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
169 #define _BIG_ENDIAN 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
170 #define linux 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
171 #define __PPC 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
172 #define __LDBL_MANT_DIG__ 106\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
173 #define __WCHAR_TYPE__ long int\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
174 #define __FLT_DIG__ 6\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
175 #define __powerpc 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
176 #define __INT_MAX__ 2147483647\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
177 #define __LONG_DOUBLE_128__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
178 #define __FLT_MAX_EXP__ 128\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
179 #define __DBL_MANT_DIG__ 53\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
180 #define __WINT_TYPE__ unsigned int\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
181 #define __LDBL_MIN_EXP__ (-968)\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
182 #define __LDBL_MAX_10_EXP__ 308\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
183 #define __DBL_EPSILON__ 2.2204460492503131e-16\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
184 #define PPC 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
185 #define powerpc 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
186 #define __INTMAX_MAX__ 9223372036854775807LL\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
187 #define __FLT_DENORM_MIN__ 1.40129846e-45F\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
188 #define __FLT_MAX__ 3.40282347e+38F\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
189 #define __FLT_MIN_10_EXP__ (-37)\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
190 #define __INTMAX_TYPE__ long long int\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
191 #define __GNUC_MINOR__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
192 #define __DBL_MAX_10_EXP__ 308\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
193 #define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
194 #define __STDC__ 1\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
195 #define __PTRDIFF_TYPE__ int\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
196 #define __LDBL_MIN_10_EXP__ (-291)\n\
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
197 "
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
198 #endif
636
72c4a8137fff String concatenation fix
kono
parents: 616
diff changeset
199 #ifdef __APPLE__
72c4a8137fff String concatenation fix
kono
parents: 616
diff changeset
200 "#define __APPLE__ 1\n"
72c4a8137fff String concatenation fix
kono
parents: 616
diff changeset
201 #endif
72c4a8137fff String concatenation fix
kono
parents: 616
diff changeset
202 ;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
203
89
917947ffeb7c power pc version
kono
parents:
diff changeset
204 #define TEXT_EMIT_MODE 0
917947ffeb7c power pc version
kono
parents:
diff changeset
205 #define DATA_EMIT_MODE 1
917947ffeb7c power pc version
kono
parents:
diff changeset
206 #define RODATA_EMIT_MODE 2
917947ffeb7c power pc version
kono
parents:
diff changeset
207
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
208 static void ld_indexx(int byte, int n, int xreg,int reg,int sign);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
209 static void local_table(void);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
210 static void shift(char *op, int creg,int reg);
444
8bec605d1701 small sized struct
kono
parents: 440
diff changeset
211 static int push_struct(int e4,int t,int arg);
518
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
212 static void ascii(char *s);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
213
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
214 #ifdef __APPLE__
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
215 static char lpfx[] = "L_";
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
216 static char npfx[] = "_";
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
217 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
218 static char lpfx[] = ".LC";
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
219 static char npfx[] = "";
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
220 #endif
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
221
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
222 int eval_order = NORMAL;
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
223
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
224 static int creg;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
225
89
917947ffeb7c power pc version
kono
parents:
diff changeset
226 static int output_mode = TEXT_EMIT_MODE;
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
227 int data_alignment = 0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
228
917947ffeb7c power pc version
kono
parents:
diff changeset
229 static int code_disp_label;
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
230 static int code_setup;
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
231 static int r1_offset_label;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
232 static int lvar_offset_label;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
233 static int max_func_arg_label;
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
234 #ifndef __APPLE__
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
235 static int arg_offset_label;
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
236 #endif
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
237 static int arg_offset_v = 0;
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
238
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
239 static int reg_save;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
240 static int freg_save;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
241
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
242 static int freg,ireg,lreg;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
243
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
244 int code_lassop_p = 1;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
245
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
246 #define SIZE_OF_INT 4
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
247 #define SIZE_OF_SHORT 2
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
248 #define SIZE_OF_FLOAT 4
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
249 #define SIZE_OF_DOUBLE 8
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
250 #define SIZE_OF_LONGLONG 8
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
251 #define ENDIAN 1
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
252 #define ENDIAN_L 1
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
253 #define ENDIAN_D 1
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
254
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
255 static int reg_sp; /* REGister Stack-Pointer */
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
256 static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
257
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
258 /* floating point registers */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
259
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
260 static int freg_sp; /* floating point REGister Stack-Pointer */
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
261 static int freg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
262
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
263 static int lreg_sp; /* longlong REGister Stack-Pointer */
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
264 static int lreg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
265
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
266 #ifdef __APPLE__
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
267 #define REG_sp 1
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
268 #define REG_fp 30
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
269 #define REG_VAR_BASE 29
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
270 #define REG_VAR_MIN 18
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
271 #define MIN_TMP_REG 3
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
272 #define MAX_TMP_REG 11
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
273
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
274 #define FREG_VAR_BASE 31
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
275 #define FREG_VAR_MIN 20
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
276 #define MIN_TMP_FREG 1
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
277 #define MAX_TMP_FREG 14
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
278 #else
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
279 #define REG_sp 1
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
280 #define REG_fp 31
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
281 #define REG_VAR_BASE 29
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
282 #define REG_VAR_MIN 18
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
283 #define MIN_TMP_REG 3
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
284 #define MAX_TMP_REG 11
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
285
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
286 #define FREG_VAR_BASE 31
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
287 #define FREG_VAR_MIN 20
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
288 #define MIN_TMP_FREG 1
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
289 #define MAX_TMP_FREG 9
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
290 #endif
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
291
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
292 int MAX_REGISTER=30; /* PowerPCのレジスタを10個まで使う*/
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
293 int MAX_FREGISTER=31;
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
294 #define REAL_MAX_REGISTER 32 /* PowerPCのレジスタが32ということ*/
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
295 #define REAL_MAX_FREGISTER 32 /* PowerPCのレジスタが32ということ*/
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
296 #define REAL_MAX_LREGISTER 16
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
297
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
298 #define FREG_OFFSET REAL_MAX_REGISTER
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
299 #define LREG_OFFSET (REAL_MAX_REGISTER+REAL_MAX_FREGISTER)
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
300
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
301 #define RET_REGISTER 3
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
302 #define RET_FREGISTER (1+FREG_OFFSET)
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
303 #define RET_LREGISTER_H 3 /* high word */
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
304 #define RET_LREGISTER_L 4 /* low word */
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
305 #define RET_LREGISTER LREG_OFFSET
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
306
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
307 int MAX_INPUT_REGISTER_VAR = 11-MIN_TMP_REG;
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
308 int MAX_CODE_INPUT_REGISTER_VAR = 11-MIN_TMP_REG;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
309 int MAX_INPUT_DREGISTER_VAR = MAX_TMP_FREG-MIN_TMP_FREG;
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
310 int MAX_INPUT_FREGISTER_VAR = MAX_TMP_FREG-MIN_TMP_FREG;
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
311 int MAX_CODE_INPUT_DREGISTER_VAR = MAX_TMP_FREG-MIN_TMP_FREG;
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
312 int MAX_CODE_INPUT_FREGISTER_VAR = MAX_TMP_FREG-MIN_TMP_FREG;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
313
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
314 static int powerpc_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER+
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
315 REAL_MAX_LREGISTER];
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
316 static int regv_h0[REAL_MAX_LREGISTER];
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
317 static int regv_l0[REAL_MAX_LREGISTER];
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
318 #define regv_h(i) regv_h0[(i)-LREG_OFFSET]
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
319 #define regv_l(i) regv_l0[(i)-LREG_OFFSET]
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
320
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
321 static int *regs = powerpc_regs;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
322
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
323 #define CREG_REGISTER (MAX_TMP_REG)
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
324 #define FREG_FREGISTER (MAX_TMP_FREG+FREG_OFFSET)
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
325 #define LREG_LREGISTER (MAX_TMP_REG+LREG_OFFSET)
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
326
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
327
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
328 static int max_reg_var, max_freg_var;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
329
805
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
330 #ifdef __APPLE__
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
331 static char *reg_name[] = {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
332 "r0","r1","r2","r3","r4","r5","r6","r7","r8","r9",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
333 "r10","r11","r12","r13","r14","r15","r16","r17","r18","r19",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
334 "r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
335 "r30","r31",
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
336 "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
337 "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
338 "f20","f21","f22","f23","f24","f25","f26","f27","f28","f29",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
339 "f30","f31"
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
340 };
805
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
341 #else
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
342 // PS3 (PowerPC Fedora Core)
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
343 static char *reg_name[] = {
805
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
344 "r0","r1","r2","r3","r4","r5","r6","r7","r8","r9",
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
345 "r10","r11","r12","r13","r14","r15","r16","r17","r18","r19",
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
346 "r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
347 "r30","r31",
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
348 "0","1","2","3","4","5","6","7","8","9",
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
349 "10","11","12","13","14","15","16","17","18","19",
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
350 "20","21","22","23","24","25","26","27","28","29",
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
351 "30","31"
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
352 };
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
353 #endif
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
354
716
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
355 #define round4(i) align(i,4)
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
356 #define round16(i) align(i,16)
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
357
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
358 #define register_name(i) reg_name[i]
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
359 #define fregister_name(i) reg_name[i]
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
360 #define lregister_name_low(i) reg_name[regv_l(i)]
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
361 #define lregister_name_high(i) reg_name[regv_h(i)]
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
362
431
800a5e3e6a17 *** empty log message ***
kono
parents: 426
diff changeset
363 #define DEBUG_REG 1
800a5e3e6a17 *** empty log message ***
kono
parents: 426
diff changeset
364 #if DEBUG_REG
467
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
365 char *rn(int i) { return register_name(i); }
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
366 char *fn(int i) { return fregister_name(i); }
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
367 char *lln(int i) { return lregister_name_low(i); }
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
368 char *lhn(int i) { return lregister_name_high(i); }
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
369 int ll(int i) { return regv_l(i); }
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
370 int lh(int i) { return regv_h(i); }
431
800a5e3e6a17 *** empty log message ***
kono
parents: 426
diff changeset
371 #endif
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
372
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
373 #define is_int_reg(i) (0<=i&&i<REAL_MAX_REGISTER)
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
374 #define is_float_reg(i) (REAL_MAX_REGISTER<=i&&i<REAL_MAX_FREGISTER+REAL_MAX_REGISTER)
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
375 #define is_longlong_reg(i) (LREG_OFFSET<=i&&i<LREG_OFFSET+REAL_MAX_LREGISTER)
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
376
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
377 #define use_int(reg) if (reg==USE_CREG) reg=use_int0()
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
378 static
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
379 int use_int0() {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
380 int i = creg;
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
381 if (!i||!ireg||!is_int_reg(i)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
382 if (lreg) { if (regs[lreg]!=REG_VAR) free_register(lreg); lreg = 0; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
383 if (!ireg) ireg = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
384 // else if (ireg!=i) free_register(i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
385 i = ireg;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
386 }
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
387 if (!regs[i]) regs[i]=USING_REG;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
388 creg = i;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
389 return i;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
390 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
391
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
392 #if LONGLONG_CODE
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
393 #define use_longlong(reg) if (reg==USE_CREG) reg=use_longlong0()
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
394
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
395 static
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
396 int use_longlong0() {
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
397 int i = creg;
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
398 if (!is_longlong_reg(i)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
399 if (ireg) { if (regs[ireg]!=REG_VAR) free_register(ireg); ireg=0; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
400 if (!lreg||!regs[lreg]) lreg = get_lregister();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
401 // else if (lreg!=i) free_register(i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
402 i = lreg;
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
403 }
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
404 if (!regv_l(i)) regv_l(i) = get_register();
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
405 if (!regv_h(i)) regv_h(i) = get_register();
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
406 if (!regs[i]) regs[i]=USING_REG;
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
407 if (!regs[regv_l(i)]) regs[regv_l(i)]=USING_REG;
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
408 if (!regs[regv_h(i)]) regs[regv_h(i)]=USING_REG;
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
409 creg = i;
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
410 return i;
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
411 }
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
412 #endif
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
413
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
414
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
415 #if FLOAT_CODE
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
416 #define use_float(d,reg) if (reg==USE_CREG) reg=d?use_double0():use_float0()
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
417 static
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
418 int use_float0() {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
419 int i = creg;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
420 if (!is_float_reg(i)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
421 if (lreg) { if (regs[lreg]!=REG_VAR) free_register(lreg); lreg = 0; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
422 if (!freg) freg = get_dregister(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
423 else if (freg!=i) if (regs[i]!=REG_VAR) free_register(i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
424 i = freg;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
425 }
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
426 if (!regs[i]) regs[i]=USING_REG;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
427 creg = i;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
428 return i;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
429 }
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
430 static
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
431 int use_double0() {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
432 int i = creg;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
433 if (!is_float_reg(i)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
434 if (lreg) { if (regs[lreg]!=REG_VAR) free_register(lreg); lreg = 0; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
435 if (!freg) freg = get_dregister(1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
436 else if (freg!=i) if (regs[i]!=REG_VAR) free_register(i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
437 i = freg;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
438 }
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
439 if (!regs[i]) regs[i]=USING_REG;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
440 creg = i;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
441 return i;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
442 }
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
443 #endif
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
444
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
445
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
446 #if FLOAT_CODE
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
447 #ifdef __APPLE__
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
448 static
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 345
diff changeset
449 NMTBL float_zero = {"_float_zero",0,STATIC,FLOAT,0};
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
450 static
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 345
diff changeset
451 NMTBL float_one = {"_float_one",0,STATIC,FLOAT,0};
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
452 #else
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
453 static
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
454 NMTBL float_zero = {"__float_zero",0,STATIC,FLOAT,0};
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
455 static
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
456 NMTBL float_one = {"__float_one",0,STATIC,FLOAT,0};
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
457 #endif
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
458
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
459
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
460 static char * fload(int d);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
461 static int code_d1(double d);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
462 static int code_d2(double d);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
463 #endif
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
464 #if LONGLONG_CODE
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
465 static int code_l1(long long ll);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
466 static int code_l2(long long ll);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
467 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
468
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
469 static void code_save_input_registers(int dots);
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
470 static void set_ireg(int,int);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
471 static void set_freg(int,int);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
472 static void set_lreg(int,int);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
473 static void jcond(int l, char cond);
431
800a5e3e6a17 *** empty log message ***
kono
parents: 426
diff changeset
474 static void register_usage(char *s);
800a5e3e6a17 *** empty log message ***
kono
parents: 426
diff changeset
475
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
476
153
33b39002ac58 MIPS continue
kono
parents: 148
diff changeset
477 static int max_func_args;
33b39002ac58 MIPS continue
kono
parents: 148
diff changeset
478 static int my_func_args;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
479 #define ARG_LVAR_OFFSET 0x10000000
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
480
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
481 /*
89
917947ffeb7c power pc version
kono
parents:
diff changeset
482
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
483 r0 return value etc.
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
484 r3-r10 input register
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
485 r22-r29 saved register variable (input register for code segment)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
486 r30 stack pointer
917947ffeb7c power pc version
kono
parents:
diff changeset
487 r31 0
917947ffeb7c power pc version
kono
parents:
diff changeset
488 r1 frame pointer
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
489
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
490 f0 return value etc.
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
491 f1-r8 input register
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
492 f24-f31 saved register variable
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
493
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
494 function call stack frame (Mac OS X)
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
495 <-------r1_offset------------------------------>
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
496 r30
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
497 <------------lvar_offset0------>
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
498 <--lvar_offset--> r1
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
499 r+ +------------+---+---------------+----------+--------------+----+ -
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
500 callee arg xx register save local caller arg xx
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
501 reg_save disp max_func_args*SIZE_OF_INT
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
502 lvar>0 lvar<0 lvar>0x1000 0000
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
503
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
504 function call stack frame (PS3)
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
505 <---------------r1_offset------------------------------>
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
506 r30-->
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
507 <--arg_offset-->
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
508 xxx<----------lvar_offset--> <----r1
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
509 r+ +------+---+------+---------------+----------+--------------+----+ -
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
510 callee arg reg arg register save local caller arg xx
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
511 reg_save disp max_func_args*SIZE_OF_INT
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
512 lvar>0 lvar<0 lvar>0x1000 0000
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
513
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
514
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
515 code segment stack frame
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
516
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
517 * gotoを呼び出した関数のr1 ! r1(goto前のr1)
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
518 # * r30 <---r1_offset---------> r1
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
519 r+ +----------+--+----------+----------------+-----------+----------+----+
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
520 cousin arg xx reg save !callee arg !code local caller arg xx
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
521 r20-r29 lvar>0 lvar<0 lvar>0x1000 000
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
522 f20-f31 <-my_func_args--><--disp-----><-max_func_arg->
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
523 *SIZE_OF_INT *SIZE_OF_INT
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
524
89
917947ffeb7c power pc version
kono
parents:
diff changeset
525 */
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
526
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
527
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
528 #ifdef __APPLE__
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
529
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
530 #define arg_offset 24
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
531 #define arg_offset1 24
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
532
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
533 #define func_disp_offset 68
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
534 #define func_disp_offset1 16
803
a5f9e5a4db1b global alignment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
535 #define code_disp_offset0 (-4)
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
536
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
537 #else
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
538
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
539 #define arg_offset (8)
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
540 #define arg_offset0 (8)
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
541 #define arg_offset1 (8)
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
542
805
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
543 #define func_disp_offset (12)
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
544 #define code_disp_offset0 (-4)
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
545
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
546 #endif
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
547
803
a5f9e5a4db1b global alignment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
548 int disp_offset = -4;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
549
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
550 #define CODE_LVAR(l) ((l)+code_disp_offset0)
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
551 #define CODE_CALLER_ARG(l) ((l)+arg_offset1)
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
552 #define FUNC_LVAR(l) ((l)+disp_offset)
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
553 #ifdef __APPLE__
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
554 #define CALLEE_ARG(l) ((l)+arg_offset)
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
555 #else
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
556 #define CALLEE_ARG(l) ((l)+arg_offset+((l>=arg_offset_v)?arg_offset0:0))
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
557 #endif
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
558 #define CALLER_ARG(l) ((l)+arg_offset1)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
559
647
fe23fe842b82 *** empty log message ***
kono
parents: 638
diff changeset
560
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
561 void
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
562 code_offset_set()
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
563 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
564 #if 0
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
565 int l;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
566 #endif
647
fe23fe842b82 *** empty log message ***
kono
parents: 638
diff changeset
567 int lvar_offsetv =
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
568 round16(-disp+max_func_args*SIZE_OF_INT)+func_disp_offset;
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
569 int r1_offsetv = round16(lvar_offsetv-reg_save);
647
fe23fe842b82 *** empty log message ***
kono
parents: 638
diff changeset
570
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
571 printf(".set %s%d,%d\n",lpfx,lvar_offset_label,r1_offsetv-lvar_offsetv);
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
572 if (r1_offsetv-lvar_offsetv > 65000) error(-1);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
573 // too large function arguments?
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
574 printf(".set %s%d,%d\n",lpfx,r1_offset_label,r1_offsetv);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
575 if (max_func_arg_label) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
576 printf(".set %s%d,%d\n",lpfx,max_func_arg_label,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
577 round16(max_func_args*SIZE_OF_INT)+24);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
578 max_func_arg_label = 0;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
579 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
580
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
581 #if 0
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
582 printf("## reg_save %d\n",reg_save);
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
583 printf("## function %s\n",fnptr->nm);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
584 l = ARG_LVAR_OFFSET;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
585 printf("## offset call0\t%d\n",CALLER_ARG);
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
586 l = ARG_LVAR_OFFSET+max_func_args*SIZE_OF_INT;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
587 printf("## offset calln\t%d %d\n",CALLER_ARG,max_func_args*SIZE_OF_INT);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
588 l = disp;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
589 printf("## offset lvarn\t%d %d\n",FUNC_LVAR+lvar_offsetv,disp);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
590 l = 0;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
591 printf("## offset lvar0\t%d\n",FUNC_LVAR+lvar_offsetv);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
592 l = -reg_save;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
593 printf("## offset regs\t%d\n",FUNC_LVAR+lvar_offsetv);
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
594 printf("## offset r1off\t%d\n",r1_offsetv);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
595 l = 0;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
596 printf("## offset carg0\t%d\n",CALLEE_ARG+r1_offsetv);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
597 l = my_func_args;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
598 printf("## offset cargn\t%d %d\n",CALLEE_ARG+r1_offsetv,my_func_args);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
599 #endif
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
600 }
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
601
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
602 static int large_offset_reg;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
603
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
604 #ifdef __APPLE__
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
605
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
606 static void
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
607 lvar(int l)
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
608 {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
609 char *rn;
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
610 if (!large_offset_reg) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
611 if (is_code(fnptr)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
612 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
613 printf("lo16(%d)(r1)\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
614 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
615 printf("lo16(%d)(r30)\n",CODE_LVAR(l));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
616 } else if (l<0) { /* local variable */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
617 printf("lo16(%d)(r30)\n",FUNC_LVAR(l));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
618 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
619 printf("lo16(%d)(r1)\n",CALLER_ARG(l-ARG_LVAR_OFFSET));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
620 } else { /* callee's arguments */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
621 printf("lo16(%d+%s%d)(r30)\n",CALLEE_ARG(l),lpfx,lvar_offset_label);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
622 }
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
623 } else {
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
624 rn = register_name(large_offset_reg);
544
dbfd6e88e2c3 s-dandy compile OK
kono
parents: 542
diff changeset
625 if (is_code(fnptr)) {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
626 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
627 printf("lo16(%d)(%s)\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET),rn);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
628 } else
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
629 printf("lo16(%d)(%s)\n",CODE_LVAR(l),rn);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
630 } else if (l<0) { /* local variable */
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
631 printf("lo16(%d)(%s)\n",FUNC_LVAR(l),rn);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
632 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
633 printf("lo16(%d)(%s)\n",CALLER_ARG(l-ARG_LVAR_OFFSET),rn);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
634 } else { /* callee's arguments */
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
635 printf("lo16(%d+%s%d)(%s)\n",CALLEE_ARG(l),lpfx,lvar_offset_label,rn);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
636 }
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
637 free_register(large_offset_reg);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
638 }
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
639 }
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
640
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
641 /* if size of local variables / input variables is more then 64k,
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
642 lo16 does not work. We have to use ha16 also. But we can't know
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
643 the exact size in one path compile. We may safely use lvar16ha
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
644 if disp or max_func_args > 32k. Of course this is redundant for
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
645 smaller offset. But who cares who use very large local variables?
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
646 */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
647
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
648 #define LARGE_OFFSET(l) (l<-32000||l>32000)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
649
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
650 static void
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
651 lvar_intro(int l)
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
652 {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
653 char *rn;
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
654 large_offset_reg=0;
544
dbfd6e88e2c3 s-dandy compile OK
kono
parents: 542
diff changeset
655 if (is_code(fnptr)) {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
656 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
657 if (LARGE_OFFSET(CODE_CALLER_ARG(l-ARG_LVAR_OFFSET))) {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
658 rn=register_name(large_offset_reg=get_register());
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
659 printf("\taddis %s,r1,ha16(%d)\n",rn,
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
660 CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
661 }
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
662 } else {
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
663 if (LARGE_OFFSET(CODE_LVAR(l))) {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
664 rn=register_name(large_offset_reg=get_register());
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
665 printf("\taddis %s,r30,ha16(%d)\n",rn,CODE_LVAR(l));
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
666 }
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
667 }
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
668 } else if (l<0) { /* local variable */
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
669 if (LARGE_OFFSET(FUNC_LVAR(l))) {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
670 rn=register_name(large_offset_reg=get_register());
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
671 printf("\taddis %s,r30,ha16(%d)\n",rn,FUNC_LVAR(l));
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
672 }
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
673 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
674 if (LARGE_OFFSET(CALLER_ARG(l-ARG_LVAR_OFFSET))) {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
675 rn=register_name(large_offset_reg=get_register());
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
676 printf("\taddis %s,r1,ha16(%d)\n",rn,CALLER_ARG(l-ARG_LVAR_OFFSET));
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
677 }
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
678 } else { /* callee's arguments */
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
679 if (LARGE_OFFSET(CALLEE_ARG(l))) {
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
680 rn=register_name(large_offset_reg=get_register());
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
681 printf("\taddis %s,r30,ha16(%d+%s%d)\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
682 rn,CALLEE_ARG(l),lpfx,lvar_offset_label);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
683 }
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
684 }
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
685 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
686
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
687 #else /* PS3 */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
688
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
689 static void
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
690 lvar(int l)
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
691 {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
692 char *rn;
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
693 if (!large_offset_reg) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
694 if (is_code(fnptr)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
695 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
696 printf("%d@l(1)\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
697 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
698 printf("%d@l(%d)\n",CODE_LVAR(l),REG_fp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
699 } else if (l<0) { /* local variable */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
700 printf("%d@l(%d)\n",FUNC_LVAR(l),REG_fp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
701 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
702 printf("%d@l(1)\n",CALLER_ARG(l-ARG_LVAR_OFFSET));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
703 } else { /* callee's arguments */
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
704 printf("%d+%s%d@l(%d)\n",CALLEE_ARG(l),lpfx,lvar_offset_label,REG_fp) ;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
705 }
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
706 } else {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
707 rn = register_name(large_offset_reg);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
708 if (is_code(fnptr)) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
709 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
710 printf("%d@l(%s)\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET),rn);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
711 } else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
712 printf("%d@l(%s)\n",CODE_LVAR(l),rn);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
713 } else if (l<0) { /* local variable */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
714 printf("%d@l(%s)\n",FUNC_LVAR(l),rn);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
715 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
716 printf("%d@l(%s)\n",CALLER_ARG(l-ARG_LVAR_OFFSET),rn);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
717 } else { /* callee's arguments */
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
718 printf("%d+%s%d@l(%s)\n",CALLEE_ARG(l),lpfx,lvar_offset_label,rn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
719 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
720 free_register(large_offset_reg);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
721 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
722 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
723
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
724 /* if size of local variables / input variables is more then 64k,
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
725 lo16 does not work. We have to use ha16 also. But we can't know
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
726 the exact size in one path compile. We may safely use lvar16ha
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
727 if disp or max_func_args > 32k. Of course this is redundant for
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
728 smaller offset. But who cares who use very large local variables?
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
729 */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
730
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
731 #define LARGE_OFFSET(l) (l<-32000||l>32000)
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
732
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
733 static void
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
734 lvar_intro(int l)
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
735 {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
736 char *rn;
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
737 large_offset_reg=0;
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
738 if (is_code(fnptr)) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
739 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
740 if (LARGE_OFFSET(CODE_CALLER_ARG(l-ARG_LVAR_OFFSET))) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
741 rn=register_name(large_offset_reg=get_register());
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
742 printf("\taddis %s,1,%d@ha\n",rn,
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
743 CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
744 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
745 } else {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
746 if (LARGE_OFFSET(CODE_LVAR(l))) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
747 rn=register_name(large_offset_reg=get_register());
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
748 printf("\taddis %s,%d,%d@ha\n",rn,REG_fp,CODE_LVAR(l));
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
749 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
750 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
751 } else if (l<0) { /* local variable */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
752 if (LARGE_OFFSET(FUNC_LVAR(l))) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
753 rn=register_name(large_offset_reg=get_register());
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
754 printf("\taddis %s,%d,%d@ha\n",rn,REG_fp,FUNC_LVAR(l));
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
755 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
756 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
757 if (LARGE_OFFSET(CALLER_ARG(l-ARG_LVAR_OFFSET))) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
758 rn=register_name(large_offset_reg=get_register());
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
759 printf("\taddis %s,1,%d@ha\n",rn,CALLER_ARG(l-ARG_LVAR_OFFSET));
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
760 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
761 } else { /* callee's arguments */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
762 if (LARGE_OFFSET(CALLEE_ARG(l))) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
763 rn=register_name(large_offset_reg=get_register());
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
764 printf("\taddis %s,%d,%d+%s%d@ha\n",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
765 rn,REG_fp,CALLEE_ARG(l),lpfx,lvar_offset_label);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
766 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
767 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
768 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
769 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
770
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
771 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
772 code_lvar(int e2,int reg) {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
773 use_int(reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
774 lvar_intro(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
775 printf("\tla %s,",register_name(reg));
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
776 lvar(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
777 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
778
89
917947ffeb7c power pc version
kono
parents:
diff changeset
779 void
917947ffeb7c power pc version
kono
parents:
diff changeset
780 code_init(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
781 {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
782 /* called only once */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
783
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
784 init_src = init_src0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
785 size_of_int = SIZE_OF_INT;
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
786 size_of_pointer = SIZE_OF_INT;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
787 size_of_short = SIZE_OF_SHORT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
788 size_of_float = SIZE_OF_FLOAT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
789 size_of_double = SIZE_OF_DOUBLE;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
790 size_of_longlong = SIZE_OF_LONGLONG;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
791 endian = ENDIAN;
717
c1542a2482b1 *** empty log message ***
kono
parents: 716
diff changeset
792 struct_align = size_of_int;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
793
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
794 regv_l(RET_LREGISTER) = RET_LREGISTER_L;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
795 regv_h(RET_LREGISTER) = RET_LREGISTER_H;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
796 }
917947ffeb7c power pc version
kono
parents:
diff changeset
797
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
798 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
799 emit_reinit()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
800 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
801 /* called for each file */
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
802 /* heap is initialized here, setup ptr cache free list */
605
1078c7e3bfb0 minor fixes
kono
parents: 603
diff changeset
803 output_mode = -1;
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
804 init_ptr_cache();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
805 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
806
89
917947ffeb7c power pc version
kono
parents:
diff changeset
807 void
917947ffeb7c power pc version
kono
parents:
diff changeset
808 gexpr_code_init(void){
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
809 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
810
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
811 void
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
812 code_gexpr(int e){
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
813 if ((is_int_reg(creg))&&regs[creg]==REG_VAR)
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
814 creg = ireg = 0;
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
815 else if (is_float_reg(creg)&&regs[creg]==REG_VAR)
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
816 creg = lreg = 0;
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
817 else if (is_longlong_reg(creg)&&regs[creg]==REG_VAR)
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
818 creg = lreg = 0;
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
819 // if (is_int_reg(creg) && creg!=ireg) error(-1);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
820 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
821
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
822 /*
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
823 set variable storage type and offset
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
824 save register contents to our stack
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
825 for & operator
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
826 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
827
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
828 void
794
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 784
diff changeset
829 code_arg_register(NMTBL *fnptr, int in)
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
830 {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
831 int args = fnptr->dsp;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
832 NMTBL *n;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
833 int reg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
834 int freg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
835 int type;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
836 int reg;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
837 int i;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
838 int is_code0 = is_code(fnptr);
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
839 int dots;
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
840 arg_offset_v = 0;
825
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
841 int offset = 0;
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
842
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
843 function_type(fnptr->ty,&dots);
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
844
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
845 if (dots && (in || !parse_mode)) {
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
846 type = INT;
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
847 mode = LDECL;
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
848 stmode = 0;
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
849 n = def(lsearch("__my_va_list",0),0);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
850 n->dsp = 0; // first argument
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
851 }
794
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 784
diff changeset
852 if (in) return;
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 784
diff changeset
853
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
854 while (args) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
855 /* process in reverse order */
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
856 n = ncadddr(args);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
857 type = n->ty;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
858 int sz = size(type);
825
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
859 offset = code_arg_alignment(offset,n,type,sz,is_code0);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
860 if (scalar(type)) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
861 if ((reg = get_input_register_var(reg_var,n,is_code0))) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
862 n->sc = REGISTER;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
863 n->dsp = cadr(reg);
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
864 regs[n->dsp]= INPUT_REG;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
865 reg_var++;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
866 arg_offset_v += (caddr(args)=SIZE_OF_INT);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
867 }
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
868 } else if (type==FLOAT) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
869 if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
870 n->sc = DREGISTER;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
871 n->dsp = cadr(reg);
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
872 regs[n->dsp]= INPUT_REG;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
873 freg_var++;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
874 arg_offset_v += (caddr(args)=size(type));
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
875 }
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
876 } else if (type==DOUBLE) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
877 if ((reg = get_input_dregister_var(freg_var,n,is_code0,1))) {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
878 n->sc = DREGISTER;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
879 n->dsp = cadr(reg);
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
880 regs[n->dsp]= INPUT_REG;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
881 freg_var++;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
882 arg_offset_v += (caddr(args)=size(type));
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
883 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
884 } else if (type==LONGLONG||type==ULONGLONG) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
885 if ((reg = get_input_lregister_var(reg_var,n,is_code0))) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
886 n->sc = LREGISTER;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
887 n->dsp = cadr(reg);
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
888 regs[i=n->dsp]= INPUT_REG;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
889 regs[regv_l(i)]= INPUT_REG;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
890 regs[regv_h(i)]= INPUT_REG;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
891 reg_var+=2;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
892 arg_offset_v += (caddr(args)=size(type));
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
893 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
894 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
895 args = cadr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
896 }
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
897 if (is_function(fnptr)) {
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
898 #ifndef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
899 if (dots) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
900 arg_offset_v =
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
901 MAX_INPUT_REGISTER_VAR*SIZE_OF_INT +
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
902 MAX_INPUT_DREGISTER_VAR*SIZE_OF_DOUBLE;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
903 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
904 printf(".set %s%d, %d\n",lpfx, arg_offset_label,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
905 arg_offset_v+ arg_offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
906 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
907 code_save_input_registers(dots);
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
908 }
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
909 }
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
910
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
911
89
917947ffeb7c power pc version
kono
parents:
diff changeset
912 int
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
913 get_register(void)
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
914 { /* 使われていないレジスタを調べる */
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
915 int i,j,reg;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
916 for(i=MAX_TMP_REG;i>MIN_TMP_REG;i--) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
917 if (regs[i]) continue; /* 使われている */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
918 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
919 return i; /* その場所を表す番号を返す */
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
920 }
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
921 /* PTR_CACHE をつぶす */
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
922 if ((i=last_ptr_cache())) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
923 clear_ptr_cache_reg(i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
924 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
925 return i; /* その場所を表す番号を返す */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
926 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
927 /* search register stack */
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
928 for(i=0;i<reg_sp;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
929 if ((reg=reg_stack[i])>=0) {
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
930 code_assign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
931 (j=new_lvar(SIZE_OF_INT)),reg,0);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
932 reg_stack[i]= j-REG_LVAR_OFFSET;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
933 return reg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
934 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
935 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
936 #if LONGLONG_CODE
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
937 /* search register stack */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
938 for(i=0;i<lreg_sp;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
939 if ((reg=lreg_stack[i])>=0) {
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
940 code_lassign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
941 (j=new_lvar(SIZE_OF_LONGLONG)),reg);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
942 lreg_stack[i]= j-REG_LVAR_OFFSET;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
943 free_register(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
944 return get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
945 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
946 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
947 #endif
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
948 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) {
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
949 reg =REG_VAR_BASE-i;
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
950 if (! regs[reg]) { /* 使われていないなら */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
951 regs[reg]=USING_REG; /* そのレジスタを使うことを宣言し */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
952 if (i>max_reg_var) max_reg_var=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
953 return reg; /* その場所を表す番号を返す */
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
954 }
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
955 }
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
956 /* 空いている場所がないなら、エラー (いったい誰が使ってるの?) */
528
d6fff671793a minor fix inline
kono
parents: 527
diff changeset
957 error(RGERR); return creg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
958 }
917947ffeb7c power pc version
kono
parents:
diff changeset
959
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
960 #if 0
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
961 int
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
962 get_register(void)
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
963 {
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
964 int i = get_register0();
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
965 printf("## get_register %d\n",i);
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
966 return i;
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
967 }
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
968 #endif
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
969
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
970 int
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
971 pop_register(void)
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
972 { /* レジスタから値を取り出す */
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
973 return reg_stack[--reg_sp];
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
974 }
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
975
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
976 #if FLOAT_CODE
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
977 int
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
978 get_dregister(int d)
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
979 { /* 使われていないレジスタを調べる */
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
980 int i,reg;
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
981 for(i=MAX_TMP_FREG+FREG_OFFSET;i>MIN_TMP_FREG+FREG_OFFSET;i--) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
982 if (regs[i]) continue; /* 使われている */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
983 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
984 return i; /* その場所を表す番号を返す */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
985 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
986 /* search register stack */
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
987 for(i=0;i<freg_sp;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
988 if ((reg=freg_stack[i])>=0) {
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
989 code_dassign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
990 (freg_stack[i]=new_lvar(SIZE_OF_DOUBLE)),reg,1);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
991 freg_stack[i]= freg_stack[i]-REG_LVAR_OFFSET;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
992 return reg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
993 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
994 }
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
995 for(i=0;i<FREG_VAR_BASE-REG_VAR_MIN;i++) {
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
996 reg =FREG_VAR_BASE-i+FREG_OFFSET;
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
997 if (! regs[reg]) { /* 使われていないなら */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
998 regs[reg]=USING_REG; /* そのレジスタを使うことを宣言し */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
999 if (i>max_freg_var) max_freg_var=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1000 return reg; /* その場所を表す番号を返す */
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
1001 }
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
1002 }
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1003 /* 空いている場所がないなら、エラー (いったい誰が使ってるの?) */
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1004 error(REG_ERR); return freg;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1005 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1006
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
1007 #if 0
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
1008 int
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
1009 get_dregister(int d)
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
1010 {
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
1011 int i = get_dregister0(d);
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
1012 printf("## get_dregister %d\n",i);
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
1013 return i;
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
1014 }
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
1015 #endif
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
1016
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1017 int
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
1018 pop_fregister(void)
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1019 { /* レジスタから値を取り出す */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1020 return freg_stack[--freg_sp];
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1021 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1022 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1023
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1024
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1025 int
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1026 get_lregister0()
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1027 {
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1028 int i;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1029 for(i=LREG_OFFSET+1;i<REAL_MAX_LREGISTER+LREG_OFFSET;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1030 if (regs[i]==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1031 return i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1032 }
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1033 }
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1034 return -1;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1035 }
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1036
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1037 static int
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1038 get_lregister1(int n,int m)
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1039 {
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1040 int i;
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1041 #if 1
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1042 for(i=LREG_OFFSET;i<REAL_MAX_LREGISTER+LREG_OFFSET;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1043 if (regv_l(i)==n && regv_h(i)==m) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1044 return i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1045 }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1046 }
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1047 #endif
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1048 return get_lregister0();
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1049 }
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1050
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1051
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1052 static void
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1053 cleanup_lregister0()
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1054 {
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1055 int i;
536
a349f9c2aef5 MIPS set_ireg/lreg interferance
kono
parents: 534
diff changeset
1056 // we should not have this, but powerpc's function
a349f9c2aef5 MIPS set_ireg/lreg interferance
kono
parents: 534
diff changeset
1057 // lost some input register variables.
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1058 #if 1
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1059 for(i=LREG_OFFSET+1;i<REAL_MAX_LREGISTER+LREG_OFFSET;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1060 if (regs[i]) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1061 if(!regv_l(i) && !regv_h(i)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1062 regs[i]=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1063 // printf("## cleanup lreg 0 %d\n",i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1064 } else if(!regs[regv_l(i)] && !regs[regv_h(i)]) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1065 free_register(i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1066 // printf("## cleanup lreg 1 %d\n",i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1067 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1068 }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1069 }
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1070 #endif
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1071 }
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1072
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1073 int
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1074 get_lregister()
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1075 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1076 int h,l,i;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1077 i = get_lregister0();
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1078 if (i==-1) return -1;
220
97246ddfe8ab *** empty log message ***
kono
parents: 219
diff changeset
1079 h = get_register();
97246ddfe8ab *** empty log message ***
kono
parents: 219
diff changeset
1080 if (h==-1) return -1;
97246ddfe8ab *** empty log message ***
kono
parents: 219
diff changeset
1081 regv_h(i) = h;
97246ddfe8ab *** empty log message ***
kono
parents: 219
diff changeset
1082 l = get_register();
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
1083 if (l==-1) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1084 if (regs[h]!=REG_VAR) free_register(h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1085 if (regs[i]!=REG_VAR) free_register(i);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1086 return -1;
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
1087 }
220
97246ddfe8ab *** empty log message ***
kono
parents: 219
diff changeset
1088 regv_l(i) = l;
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
1089 if (!regs[i]) regs[i]=USING_REG;
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1090 // printf("## get_lregister %d %s %s\n",i, lregister_name_high(i), lregister_name_low(i));
220
97246ddfe8ab *** empty log message ***
kono
parents: 219
diff changeset
1091 return i;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1092 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1093
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1094 int
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1095 get_lregister_var(NMTBL *n)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1096 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1097 int i,j,ll;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1098 int max_reg_var_save=max_reg_var;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1099 ll = get_lregister0();
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
1100 if (ll==-1) goto not_found;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1101 if (regs[ll]==0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1102 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1103 if (! regs[REG_VAR_BASE-i]) { /* 使われていないなら */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1104 /* そのレジスタを使うことを宣言し */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1105 regs[REG_VAR_BASE-i]=USING_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1106 if (i>max_reg_var) max_reg_var=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1107 for(j=0;j<REG_VAR_BASE-REG_VAR_MIN;j++) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1108 if (! regs[REG_VAR_BASE-j]) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1109 /* 使われていないなら */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1110 /* そのレジスタを使うことを宣言し */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1111 regs[REG_VAR_BASE-j]=REG_VAR;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1112 if (j>max_reg_var) max_reg_var=j;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1113 /* その場所を表す番号を返す */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1114 regs[ll]=REG_VAR;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1115 regv_l(ll) = REG_VAR_BASE-j;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1116 regv_h(ll) = REG_VAR_BASE-i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1117 return list3n(LREGISTER,ll,n);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1118 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1119 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1120 /* ひとつしかなかった */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1121 regs[REG_VAR_BASE-i]=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1122 max_reg_var=max_reg_var_save;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1123 goto not_found;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1124 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1125 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1126 }
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1127 not_found:
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1128 return list3n(LVAR,new_lvar(SIZE_OF_LONGLONG),0);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1129 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1130
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1131 void
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1132 emit_pop_free(int xreg)
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1133 {
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
1134 if (xreg>=0 && xreg!=creg && regs[xreg]!=REG_VAR)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1135 free_register(xreg);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1136 }
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1137
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
1138 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
1139
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1140 free_register(int i) { /* いらなくなったレジスタを開放 */
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
1141 // printf("## free_register %d\n",i);
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1142 if (is_longlong_reg(i)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1143 regs[regv_l(i)]=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1144 regs[regv_h(i)]=0;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1145 }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1146 regs[i]=0;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1147 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1148
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1149 extern void
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1150 use_ptr_cache(int r)
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1151 {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1152 regs[r]=PTRC_REG;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1153 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1154
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1155 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1156 get_input_dregister_var(int i,NMTBL *n,int is_code,int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1157 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1158 if (is_code) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1159 if(!(i<FREG_VAR_BASE-FREG_VAR_MIN)) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1160 i = FREG_VAR_BASE-i+FREG_OFFSET;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1161 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1162 if (i<0||i>=MAX_INPUT_DREGISTER_VAR) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1163 i = i+MIN_TMP_FREG+FREG_OFFSET;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1164 }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1165 return list3n(DREGISTER,i,n);
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1166 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1167
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1168 int
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1169 get_input_lregister_var(int i,NMTBL *n,int is_code)
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1170 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1171 int ll;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1172 if (i!=-1) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1173 if (is_code) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1174 if(!(i<REG_VAR_BASE-REG_VAR_MIN)) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1175 i = REG_VAR_BASE-i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1176 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1177 if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
1178 #ifndef __APPLE__
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
1179 if (i%2==1) i++;
674
68d70527b0c0 *** empty log message ***
kono
parents: 673
diff changeset
1180 #endif
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1181 i = i+MIN_TMP_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1182 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1183 ll = get_lregister1(i,i+1);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
1184 #if ENDIAN_L==0
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1185 regv_l(ll)=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1186 regv_h(ll)=i+1;
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
1187 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1188 regv_h(ll)=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1189 regv_l(ll)=i+1;
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
1190 #endif
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1191 } else { error(-1); ll=LREG_OFFSET+2; }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1192 return list3n(LREGISTER,ll,n);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1193 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1194
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1195 int
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1196 get_input_register_var(int i,NMTBL *n,int is_code)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1197 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1198 if (is_code) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1199 if(!(i<REG_VAR_BASE-REG_VAR_MIN)) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1200 i = REG_VAR_BASE-i;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1201 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1202 if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1203 i = i+MIN_TMP_REG;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1204 }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1205 return list3n(REGISTER,i,n);
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1206 }
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1207
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
1208 /* double register case? */
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
1209
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1210 int
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1211 get_input_register_var_1(int i,NMTBL *n,int is_code)
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1212 {
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1213 if (is_code) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1214 if(!(i<REG_VAR_BASE-REG_VAR_MIN)) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1215 i = REG_VAR_BASE-i;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
1216 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1217 if (i<0||i>=MAX_INPUT_REGISTER_VAR+1) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1218 i = i+MIN_TMP_REG;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1219 }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1220 return list3n(REGISTER,i,n);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1221 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1222
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1223 int
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1224 free_register_count(int d)
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1225 {
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1226 int i,count,fcount;
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1227 fcount = count = 0;
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1228 for(i=0;i<MAX_REGISTER;i++) {
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1229 if (! regs[i]) count++;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1230 }
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1231 for(i=0;i<MAX_FREGISTER;i++) {
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1232 if (! regs[i+FREG_OFFSET]) fcount++;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1233 }
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
1234 printf("## free reg %d freg %d\n",count,fcount);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1235 return d?fcount:count;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1236 }
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1237
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1238 #if 0
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1239 static int
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1240 register_full(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
1241 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1242 int i;
917947ffeb7c power pc version
kono
parents:
diff changeset
1243 for(i=0;i<MAX_REGISTER;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1244 if (! regs[i]) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1245 return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1246 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1247 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1248 return 1;
917947ffeb7c power pc version
kono
parents:
diff changeset
1249 }
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1250 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1251
917947ffeb7c power pc version
kono
parents:
diff changeset
1252 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1253 free_all_register(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
1254 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1255 int i;
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
1256 // printf("## free_all register\n");
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1257 #if LONGLONG_CODE
226
a31e1d24c097 *** empty log message ***
kono
parents: 223
diff changeset
1258 for(i=0;i<REAL_MAX_LREGISTER;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1259 regs[i+LREG_OFFSET]=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1260 regv_l(i+LREG_OFFSET) = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1261 regv_h(i+LREG_OFFSET) = 0;
226
a31e1d24c097 *** empty log message ***
kono
parents: 223
diff changeset
1262 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1263 lreg = 0;
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
1264 // set_lreg(LREG_LREGISTER,0);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1265 #endif
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1266 for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1267 for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1268 #if FLOAT_CODE
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1269 freg = get_dregister(1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1270 set_freg(FREG_FREGISTER,0);
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1271 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1272 ireg = creg = get_register();
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1273 set_ireg(CREG_REGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1274 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1275 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1276
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1277 extern int
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1278 code_register_overlap(int s,int t)
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1279 {
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1280 switch(car(s)) {
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1281 case REGISTER:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1282 switch(car(t)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1283 case DREGISTER: case FREGISTER: break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1284 case REGISTER:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1285 if(cadr(s)==cadr(t)) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1286 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1287 case LREGISTER:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1288 if(cadr(s)==regv_l(cadr(t))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1289 if(cadr(s)==regv_h(cadr(t))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1290 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1291 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1292 break;
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1293 case DREGISTER:
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1294 case FREGISTER:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1295 switch(car(t)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1296 case REGISTER: case LREGISTER: break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1297 case DREGISTER: case FREGISTER:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1298 if(cadr(s)==cadr(t)) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1299 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1300 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1301 break;
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1302 case LREGISTER:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1303 switch(car(t)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1304 case DREGISTER: case FREGISTER: break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1305 case REGISTER:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1306 if(cadr(t)==regv_l(cadr(s))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1307 if(cadr(t)==regv_h(cadr(s))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1308 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1309 case LREGISTER:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1310 if(regv_l(cadr(t))==regv_l(cadr(s))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1311 if(regv_l(cadr(t))==regv_h(cadr(s))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1312 if(regv_h(cadr(t))==regv_l(cadr(s))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1313 if(regv_h(cadr(t))==regv_h(cadr(s))) return 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1314 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1315 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1316 break;
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1317 }
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1318 return 0;
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1319 }
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
1320
531
19f5882997f5 *** empty log message ***
kono
parents: 530
diff changeset
1321 // int lreg_count;
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1322
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1323 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1324 register_usage(char *s)
917947ffeb7c power pc version
kono
parents:
diff changeset
1325 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
1326 #if 1
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1327 int i,j;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1328 #endif
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1329 #define USAGE_MAX 4
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1330 if (!lsrc) return;
467
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
1331 printf("## %d: %s:",lineno,s);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1332 if (ireg) printf(" creg=%s",register_name(ireg));
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1333 if (freg) printf(" freg=%s",fregister_name(freg));
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1334 if (lreg) printf(" lreg=%s,%s",lregister_name_high(lreg),
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1335 lregister_name_low(lreg));
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1336 #if 1
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1337 for(j=0,i=0;i<MAX_REGISTER;i++) if (regs[i]) j++;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1338 if (j>USAGE_MAX) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1339 printf("\n## regs(%d):",j);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1340 for(i=0;i<MAX_REGISTER;i++) { printf("%d",regs[i]); }
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1341 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1342 if (reg_sp>0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1343 printf(" stack ");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1344 for(i=reg_sp;i>0;i--) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1345 if(reg_stack[i-1]>=0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1346 printf(" %s",register_name(reg_stack[i-1]));
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1347 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1348 printf(",%d",reg_stack[i-1]);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1349 }
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1350 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1351 for(j=0,i=0;i<MAX_FREGISTER;i++) if (regs[i+FREG_OFFSET]) j++;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1352 if (j>USAGE_MAX) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1353 printf("\n## freg(%d):",j);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1354 for(i=0;i<MAX_FREGISTER;i++) { printf("%d",regs[i+FREG_OFFSET]); }
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1355 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1356 if (freg_sp>0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1357 printf(" fstack ");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1358 for(i=freg_sp;i>0;i--) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1359 if(freg_stack[i-1]>=0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1360 printf(" %s",fregister_name(freg_stack[i-1]));
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1361 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1362 printf(",%d",freg_stack[i-1]);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1363 }
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1364 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1365
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1366 for(j=0,i=0;i<REAL_MAX_LREGISTER;i++) if (regs[i+LREG_OFFSET]) j++;
531
19f5882997f5 *** empty log message ***
kono
parents: 530
diff changeset
1367 // lreg_count = j;
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1368 if (j>USAGE_MAX) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1369 printf("\n## lreg(%d):",j);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1370 for(i=0;i<REAL_MAX_LREGISTER;i++) { printf("%d",regs[i+LREG_OFFSET]); }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1371 #if 0
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1372 for(i=0;i<REAL_MAX_LREGISTER;i++) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1373 if (regs[i+LREG_OFFSET] && regv_l(i+LREG_OFFSET))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1374 printf(" %s-%s", lregister_name_high(i+LREG_OFFSET),lregister_name_low(i+LREG_OFFSET));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1375 else if (regv_l(i+LREG_OFFSET))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1376 printf(" *%s-%s", lregister_name_high(i+LREG_OFFSET),lregister_name_low(i+LREG_OFFSET));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1377 }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1378 #endif
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1379 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1380 if (lreg_sp>0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1381 printf(" lstack ");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1382 for(i=lreg_sp;i>0;i--) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1383 if(lreg_stack[i-1]>=0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1384 printf(" %s",lregister_name_high(lreg_stack[i-1]));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1385 printf(",%s",lregister_name_low(lreg_stack[i-1]));
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1386 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1387 printf(",%d",lreg_stack[i-1]);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1388 }
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1389 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1390 #endif
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1391 printf("\n");
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1392 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
1393
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
1394 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
1395
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1396 gexpr_init(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
1397 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1398 while(reg_sp > 0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1399 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1400 free_register(reg_stack[--reg_sp]);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1401 }
148
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
1402 while(freg_sp > 0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1403 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1404 free_register(freg_stack[--freg_sp]);
148
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
1405 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1406 while(lreg_sp > 0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1407 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1408 free_register(lreg_stack[--lreg_sp]);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1409 }
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1410 use_int0();
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
1411 text_mode(0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1412 gexpr_code_init();
917947ffeb7c power pc version
kono
parents:
diff changeset
1413 register_usage("gexpr_init");
917947ffeb7c power pc version
kono
parents:
diff changeset
1414 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1415
917947ffeb7c power pc version
kono
parents:
diff changeset
1416
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
1417 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
1418
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1419 emit_init(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
1420 {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1421 /* called before each declaration */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1422
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1423 free_all_register();
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
1424 max_reg_var=-1; max_freg_var=-1;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1425 reg_sp = 0;
123
5f180dc8d84e intel fix.
kono
parents: 122
diff changeset
1426 freg_sp = 0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1427 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1428
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
1429
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1430 int
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1431 get_register_var(NMTBL *n)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1432 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1433 int i;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1434 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1435 if (! regs[REG_VAR_BASE-i]) { /* 使われていないなら */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1436 /* そのレジスタを使うことを宣言し */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1437 regs[REG_VAR_BASE-i]=REG_VAR;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1438 if (i>max_reg_var) max_reg_var=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1439 /* その場所を表す番号を返す */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1440 return list3n(REGISTER,REG_VAR_BASE-i,n);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1441 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1442 }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1443 return list3n(LVAR,new_lvar(SIZE_OF_INT),0);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1444 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1445
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1446 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1447 get_dregister_var(NMTBL *n,int d)
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1448 {
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1449 int i;
148
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
1450 for(i=0;i<FREG_VAR_BASE-FREG_VAR_MIN;i++) {
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1451 if (! regs[FREG_VAR_BASE-i+FREG_OFFSET]) { /* 使われていないなら */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1452 regs[FREG_VAR_BASE-i+FREG_OFFSET]=REG_VAR; /*そのレジスタを使うことを宣言し*/
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1453 if (i>max_freg_var) max_freg_var=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1454 /* その場所を表す番号を返す */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1455 return list3n(DREGISTER,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1456 FREG_VAR_BASE-i+FREG_OFFSET,n);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1457 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1458 }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1459 return list3n(LVAR,new_lvar(SIZE_OF_DOUBLE),0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1460 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1461
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
1462 int
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1463 emit_push()
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1464 {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
1465 int new_reg,old=creg;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1466 if (!is_int_reg(creg)) error(-1);
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
1467 if (reg_sp>MAX_MAX) error(-1);
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1468 new_reg = get_register(); /* 絶対に取れる */
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
1469 if (new_reg==creg) error(-1); // freed creg
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1470 reg_stack[reg_sp++] = creg; /* push するかわりにレジスタを使う */
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1471 ireg = creg = new_reg;
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
1472 if (!regs[creg]) regs[creg]=USING_REG;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
1473 return old;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1474 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1475
917947ffeb7c power pc version
kono
parents:
diff changeset
1476 int
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1477 emit_pop(int type)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1478 {
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
1479 int xreg,reg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
1480 xreg=pop_register();
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
1481 if (xreg<= -REG_LVAR_OFFSET) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1482 reg = get_register();
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1483 code_rlvar(REG_LVAR_OFFSET+xreg,reg);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1484 free_lvar(REG_LVAR_OFFSET+xreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1485 xreg = reg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
1486 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1487 return xreg;
917947ffeb7c power pc version
kono
parents:
diff changeset
1488 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1489
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1490 #ifdef __APPLE__
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
1491 static int code_base;
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1492 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1493
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1494 extern void
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1495 code_ptr_cache_def(int r,NMTBL *nptr)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1496 {
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
1497 char *rrn = register_name(r);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1498 #ifdef __APPLE__
544
dbfd6e88e2c3 s-dandy compile OK
kono
parents: 542
diff changeset
1499 if (nptr->sc==STATIC && !(is_code(nptr)||is_function(nptr))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1500 printf("\taddis %s,r31,ha16(_%s-L_%d)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1501 rrn,nptr->nm,code_base);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1502 printf("\tla %s,lo16(_%s-L_%d)(%s)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1503 rrn,nptr->nm,code_base,rrn);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1504 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1505 printf("\taddis %s,r31,ha16(L_%s$non_lazy_ptr-L_%d)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1506 rrn,nptr->nm,code_base);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1507 printf("\tlwz %s,lo16(L_%s$non_lazy_ptr-L_%d)(%s)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1508 rrn,nptr->nm,code_base,rrn);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1509 }
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1510 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1511 printf("\tlis %s,%s@ha\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1512 rrn,nptr->nm);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1513 printf("\tla %s,%s@l(%s)\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1514 rrn,nptr->nm,rrn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1515 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1516 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1517
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
1518 static char *cload(int sz) { return sz==1?"lbz":sz==SIZE_OF_SHORT?"lhz":"lwz"; }
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
1519 static char *cstore(int sz) { return sz==1?"stb":sz==SIZE_OF_SHORT?"sth":"stw"; }
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1520
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1521 static void
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1522 cext(int sign,int sz,int reg)
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1523 {
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1524 char *crn = register_name(reg);
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1525 if (sign) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1526 if (sz==1)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1527 printf("\textsb %s,%s\n",crn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1528 else if (sz==SIZE_OF_SHORT)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1529 printf("\textsh %s,%s\n",crn,crn);
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1530 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1531 if (sz==1)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1532 printf("\trlwinm %s,%s,0,0xff\n",crn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1533 else if (sz==SIZE_OF_SHORT)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1534 printf("\trlwinm %s,%s,0,0xffff\n",crn,crn);
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1535 }
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1536 }
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1537
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1538
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1539 void
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1540 code_label(int labelno)
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1541 {
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1542 clear_ptr_cache();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1543 printf("%s%d:\n",lpfx,labelno);
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1544 }
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1545
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1546 static void
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1547 code_add(int reg,int offset,int r)
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1548 {
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1549 char *crn = register_name(reg);
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1550 char *rrn = register_name(r);
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1551 if (offset==0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1552 if(r!=reg)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1553 printf("\tmr %s,%s\n",crn,rrn);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
1554 } else if (LARGE_OFFSET(offset)) {
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1555 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1556 printf("\tla %s,lo16(%d)(%s)\n",crn,offset,rrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1557 printf("\taddis %s,%s,ha16(%d)\n",crn,crn,offset);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1558 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1559 printf("\tla %s,%d@l(%s)\n",crn,offset,rrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1560 printf("\taddis %s,%s,%d@ha\n",crn,crn,offset);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1561 #endif
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1562 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1563 printf("\taddi %s,%s,%d\n",crn,rrn,offset);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1564 }
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1565
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1566 static void
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1567 code_ld(char *ld,int reg,int offset,int r)
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1568 {
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1569 char *crn = register_name(reg);
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1570 char *rrn = register_name(r);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
1571 if (LARGE_OFFSET(offset)) {
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1572 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1573 printf("\taddis %s,%s,ha16(%d)\n",crn,rrn,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1574 printf("\t%s %s,lo16(%d)(%s)\n",ld,crn,offset,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1575 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1576 printf("\taddis %s,%s,%d@ha\n",crn,rrn,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1577 printf("\t%s %s,%d@l(%s)\n",ld,crn,offset,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1578 #endif
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1579 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1580 printf("\t%s %s,%d(%s)\n",ld,crn,offset,rrn);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1581 }
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1582
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1583 static void
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1584 code_ldf(char *ld,char *crn,int offset,int r)
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1585 {
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1586 char *rrn = register_name(r);
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1587 int reg;
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1588 char *lrn;
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1589 if (offset<-32768||32767<offset) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1590 lrn = register_name(reg = get_register());
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1591 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1592 printf("\taddis %s,%s,ha16(%d)\n",lrn,rrn,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1593 printf("\t%s %s,lo16(%d)(%s)\n",ld,crn,offset,lrn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1594 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1595 printf("\taddis %s,%s,%d@ha\n",lrn,rrn,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1596 printf("\t%s %s,%d@l(%s)\n",ld,crn,offset,lrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1597 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1598 free_register(reg);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1599 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1600 printf("\t%s %s,%d(%s)\n",ld,crn,offset,rrn);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1601 }
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1602
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1603 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1604 code_gvar(int e1,int reg) {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1605 use_int(reg);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1606 code_add(reg,cadr(e1),get_ptr_cache(ncaddr(e1)));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1607 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1608 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1609
917947ffeb7c power pc version
kono
parents:
diff changeset
1610 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1611 code_rgvar(int e1,int reg) {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1612 use_int(reg);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1613 code_ld("lwz",reg,cadr(e1),get_ptr_cache(ncaddr(e1)));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1614 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1615
917947ffeb7c power pc version
kono
parents:
diff changeset
1616 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1617 code_crgvar(int e1,int reg,int sign,int sz){
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1618 use_int(reg);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1619 code_ld(cload(sz),reg,cadr(e1),get_ptr_cache(ncaddr(e1)));
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1620 cext(sign,sz,reg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1621 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1622
165
kono
parents: 164
diff changeset
1623
kono
parents: 164
diff changeset
1624
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1625 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1626 code_register(int e2,int reg) {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1627 use_int(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1628 if (reg!=e2)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1629 printf("\tmr %s,%s\n",register_name(reg),register_name(e2));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1630 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1631
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1632 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1633 code_i2c(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1634 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1635 use_int(reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1636 cext(1,1,reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1637 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1638
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1639 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1640 code_i2s(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1641 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1642 use_int(reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1643 cext(1,SIZE_OF_SHORT,reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1644 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1645
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1646 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1647 code_u2uc(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1648 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1649 use_int(reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1650 cext(0,1,reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1651 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1652
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1653 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1654 code_u2us(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1655 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1656 use_int(reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1657 cext(0,SIZE_OF_SHORT,reg);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1658 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1659
917947ffeb7c power pc version
kono
parents:
diff changeset
1660 void
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1661 code_rlvar(int e2,int reg) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1662 use_int(reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1663 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1664 printf("\tlwz %s,",register_name(reg));
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1665 lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1666 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1667
917947ffeb7c power pc version
kono
parents:
diff changeset
1668 void
165
kono
parents: 164
diff changeset
1669 code_crlvar(int e2,int reg,int sign,int sz) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1670 use_int(reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1671 lvar_intro(e2);
165
kono
parents: 164
diff changeset
1672 printf("\t%s %s,",cload(sz),register_name(reg));
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1673 lvar(e2);
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1674 cext(sign,sz,reg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1675 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1676
917947ffeb7c power pc version
kono
parents:
diff changeset
1677 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1678 code_fname(NMTBL *n,int reg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1679 int r;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1680 use_int(reg);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1681 r = get_ptr_cache(n);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1682 if(r!=reg)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1683 printf("\tmr %s,%s\n",register_name(reg),register_name(r));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1684 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1685 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1686
363
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1687 void
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1688 code_label_value(int label,int reg) {
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1689 char *crn;
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1690 use_int(reg);
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1691 crn = register_name(reg);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1692 #ifdef __APPLE__
363
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1693 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",crn,label,code_base);
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1694 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",crn,label,code_base,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1695 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1696 printf("\tlis %s,.LC%d@ha\n",crn,label);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1697 printf("\tla %s,.LC%d@l(%s)\n",crn,label,crn);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1698 #endif
363
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1699 return;
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1700 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1701
917947ffeb7c power pc version
kono
parents:
diff changeset
1702 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1703 code_const(int e2,int reg) {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1704 char *crn;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1705 use_int(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1706 crn = register_name(reg);
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
1707 // printf("## 0x%08x\n",e2);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1708 #ifdef __APPLE__
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1709 if (-32768<e2&&e2<32768)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1710 printf("\tli %s,%d\n",crn,e2);
599
df04bc5fd5fe *** empty log message ***
kono
parents: 594
diff changeset
1711 else if ((e2&0xffff)==0)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1712 printf("\tlis %s,ha16(%d)\n",crn,e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1713 else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1714 printf("\tlis %s,ha16(%d)\n",crn,e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1715 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1716 }
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1717 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1718 if (-32768<e2&&e2<32768)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1719 printf("\tli %s,%d\n",crn,e2);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1720 else if ((e2&0xffff)==0)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1721 printf("\tlis %s,%d@ha\n",crn,e2);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1722 else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1723 printf("\tlis %s,%d@ha\n",crn,e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1724 printf("\taddi %s,%s,%d@l\n",crn,crn,e2);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1725 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1726 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1727 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1728
917947ffeb7c power pc version
kono
parents:
diff changeset
1729 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1730 code_neg(int creg) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1731 use_int(creg);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1732 printf("\tneg %s,%s\n", register_name(creg), register_name(creg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1733 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1734
917947ffeb7c power pc version
kono
parents:
diff changeset
1735
917947ffeb7c power pc version
kono
parents:
diff changeset
1736 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1737 code_not(int creg) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1738 use_int(creg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1739 printf("\tnor %s,%s,%s\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1740 register_name(creg), register_name(creg),register_name(creg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1741 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1742
917947ffeb7c power pc version
kono
parents:
diff changeset
1743
917947ffeb7c power pc version
kono
parents:
diff changeset
1744 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1745 code_lnot(int creg) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1746 use_int(creg);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1747 #ifdef __APPLE__
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1748 printf("\tsubfic r0,%s,0\n", register_name(creg));
917947ffeb7c power pc version
kono
parents:
diff changeset
1749 printf("\tadde %s,r0,%s\n", register_name(creg),register_name(creg));
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1750 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1751 printf("\tsubfic 0,%s,0\n", register_name(creg));
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1752 printf("\tadde %s,0,%s\n", register_name(creg),register_name(creg));
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1753 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1754 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1755
917947ffeb7c power pc version
kono
parents:
diff changeset
1756 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1757 code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1758 char *xrn,*drn;
917947ffeb7c power pc version
kono
parents:
diff changeset
1759 if (car(e2)==REGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1760 use_int(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1761 printf("\taddi %s,%s,%d\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1762 register_name(cadr(e2)),register_name(cadr(e2)), dir);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1763 if (use && cadr(e2)!=reg)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1764 printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2)));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1765 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1766 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1767 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1768 if (!is_int_reg(creg)) error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1769 xrn = register_name(creg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1770 if (reg==USE_CREG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1771 reg=get_register(); if (!reg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1772 drn = register_name(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1773 set_ireg(reg,0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1774 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1775 drn = register_name(reg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1776 }
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1777 printf("\t%s %s,0(%s)\n",cload(sz),drn,xrn);
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
1778 if (use) cext(sign,sz,reg);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1779 printf("\taddi %s,%s,%d\n",drn,drn,dir);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1780 printf("\t%s %s,0(%s)\n",cstore(sz),drn,xrn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1781 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1782
917947ffeb7c power pc version
kono
parents:
diff changeset
1783
917947ffeb7c power pc version
kono
parents:
diff changeset
1784 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1785 code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1786 char *xrn,*crn,*nrn;
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
1787 int nreg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1788 if (car(e2)==REGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1789 use_int(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1790 if (use)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1791 printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2)));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1792 printf("\taddi %s,%s,%d\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1793 register_name(cadr(e2)),register_name(cadr(e2)),dir);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1794 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1795 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1796 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1797 if (!is_int_reg(creg)) error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1798 crn = register_name(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1799 nreg=get_register(); if (!nreg) error(-1);
917947ffeb7c power pc version
kono
parents:
diff changeset
1800 nrn = register_name(nreg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1801 if (reg==USE_CREG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1802 reg=get_register(); if (!reg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1803 xrn = register_name(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1804 set_ireg(reg,0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1805 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1806 xrn = register_name(reg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1807 }
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1808 printf("\t%s %s,0(%s)\n",cload(sz),xrn,crn);
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1809 if (use) cext(sign,sz,reg);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1810 printf("\taddi %s,%s,%d\n",nrn,xrn,dir);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1811 printf("\t%s %s,0(%s)\n",cstore(sz),nrn,crn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1812 free_register(nreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1813 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1814
917947ffeb7c power pc version
kono
parents:
diff changeset
1815
917947ffeb7c power pc version
kono
parents:
diff changeset
1816 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1817 code_return(int creg) {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1818
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1819 use_int(creg);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1820 code_label_value(retcont,creg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1821 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1822
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
1823 #define R1SAVE 0
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1824
917947ffeb7c power pc version
kono
parents:
diff changeset
1825 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1826 code_environment(int creg) {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1827 /* save frame pointer */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1828 use_int(creg);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1829 #if R1SAVE
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1830 printf("\tlwz %s,0(%s)\n",register_name(creg),register_name(1));
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1831 #else
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
1832 printf("\tmr %s,%s\n",register_name(creg),register_name(REG_fp));
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
1833 // int l = 0;
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
1834 // printf("\tla %s,",register_name(creg));
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
1835 // printf("lo16(%d+L_%d)(r30)\n",FUNC_LVAR,lvar_offset_label);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1836 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1837 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1838
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1839 static int rexpr_bool(int e1,int reg);
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1840
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1841 #if FLOAT_CODE
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1842 static int drexpr_bool(int e1,int reg);
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1843 #endif
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1844
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1845 #if LONGLONG_CODE
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1846 static int lrexpr_bool(int e1,int reg)
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1847 {
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1848 return 0;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1849 }
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1850 #endif
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1851
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1852
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1853
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1854 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1855 code_bool(int e1,int reg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1856 char *xrn;
917947ffeb7c power pc version
kono
parents:
diff changeset
1857 int e2,e3;
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1858
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1859 if (rexpr_bool(e1,reg)) return;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1860 #if FLOAT_CODE
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1861 else if (drexpr_bool(e1,reg)) return;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1862 #endif
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1863 #if LONGLONG_CODE
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1864 else if (lrexpr_bool(e1,reg)) return;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1865 #endif
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
1866
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1867 b_expr(e1,1,e2=fwdlabel(),1); /* including > < ... */
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
1868 if (use) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1869 use_int(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1870 xrn = register_name(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1871 printf("\tli %s,0\n",xrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1872 jmp(e3=fwdlabel());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1873 fwddef(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1874 printf("\tli %s,1\n",xrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1875 fwddef(e3);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
1876 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1877 fwddef(e2);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
1878 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1879 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1880
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1881 #define code_gt(cond) (cond?"gt":"le")
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1882
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1883 #define code_ugt(cond) (cond?"gt":"le")
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1884
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1885 #define code_ge(cond) (cond?"ge":"lt")
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1886
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1887 #define code_uge(cond) (cond?"ge":"lt")
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1888
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
1889 #define code_eq(cond) (cond?"eq":"ne")
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1890
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
1891 static int cmpflag = 7;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
1892
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
1893 static void
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
1894 inc_cmpflag()
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
1895 {
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
1896 // gcc use cmpflag 4 and 7, and gcc4 believes flag 4 is preserved.
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
1897 do {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1898 cmpflag = (cmpflag+1)%8;
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
1899 } while (cmpflag!=4 && cmpflag!=7);
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
1900 }
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
1901
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1902 #ifdef __APPLE__
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1903 static
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1904 char *crname_[] = { "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7" };
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1905 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1906 static
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1907 char *crname_[] = { "0", "1", "2", "3", "4", "5", "6", "7" };
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1908 #endif
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1909 #define crname(d) (crname_[d])
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1910
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1911 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1912 code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1913 use_int(reg);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1914 code_ld(cload(sz),reg,cadr(e1),get_ptr_cache(ncaddr(e1)));
432
f8ebd7e1c644 *** empty log message ***
kono
parents: 431
diff changeset
1915 cext(0,sz,reg);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1916 inc_cmpflag();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1917 printf("\tcmpwi %s,%s,0\n",crname(cmpflag),register_name(reg));
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1918 jcond(label,cond);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1919 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1920
917947ffeb7c power pc version
kono
parents:
diff changeset
1921
917947ffeb7c power pc version
kono
parents:
diff changeset
1922 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1923 code_cmp_crlvar(int e2,int reg, int sz,int label,int cond) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1924 char *crn;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1925 use_int(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1926 crn = register_name(reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1927 lvar_intro(e2);
167
0197ca125567 mips short
kono
parents: 165
diff changeset
1928 printf("\t%s %s,",cload(sz),crn);
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1929 lvar(e2);
230
d60c6c31f63a *** empty log message ***
kono
parents: 229
diff changeset
1930 cext(0,sz,reg);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1931 code_cmp_register(reg,label,cond);
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1932 }
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1933
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1934
917947ffeb7c power pc version
kono
parents:
diff changeset
1935 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1936 code_cmp_rgvar(int e1,int reg,int label,int cond) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1937 use_int(reg);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1938 code_ld("lwz",reg,cadr(e1),get_ptr_cache(ncaddr(e1)));
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1939 code_cmp_register(reg,label,cond);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1940 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1941
917947ffeb7c power pc version
kono
parents:
diff changeset
1942
917947ffeb7c power pc version
kono
parents:
diff changeset
1943 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1944 code_cmp_rlvar(int e2,int reg,int label,int cond) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1945 char *crn;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1946 use_int(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1947 crn = register_name(reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1948 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1949 printf("\tlwz %s,",crn);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1950 lvar(e2);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1951 code_cmp_register(reg,label,cond);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1952 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1953
917947ffeb7c power pc version
kono
parents:
diff changeset
1954
917947ffeb7c power pc version
kono
parents:
diff changeset
1955 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1956 code_cmp_register(int e2,int label,int cond) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1957 use_int(e2);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1958 inc_cmpflag();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
1959 printf("\tcmpwi %s,%s,0\n",crname(cmpflag),register_name(e2));
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
1960 jcond(label,cond);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1961 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1962
917947ffeb7c power pc version
kono
parents:
diff changeset
1963
917947ffeb7c power pc version
kono
parents:
diff changeset
1964 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1965 code_string(int e1,int creg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1966 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1967 int lb;
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1968 NMTBL *n = ncaddr(e1);
560
d6ff45d719a5 string sharing
kono
parents: 556
diff changeset
1969 if ((lb=attr_value(n,LABEL))) {
d6ff45d719a5 string sharing
kono
parents: 556
diff changeset
1970 // already defined
d6ff45d719a5 string sharing
kono
parents: 556
diff changeset
1971 return code_label_value(lb,creg) ;
d6ff45d719a5 string sharing
kono
parents: 556
diff changeset
1972 }
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1973
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1974 use_int(creg);
319
88cf6512fa1b asm for powerpc done.
kono
parents: 318
diff changeset
1975 lb = emit_string_label();
560
d6ff45d719a5 string sharing
kono
parents: 556
diff changeset
1976 ascii(n->nm);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1977 if (output_mode==TEXT_EMIT_MODE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1978 printf(".text\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1979 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
1980 text_mode(0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1981 }
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
1982 code_label_value(lb,creg);
560
d6ff45d719a5 string sharing
kono
parents: 556
diff changeset
1983 set_attr(n,LABEL,lb);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1984 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1985
778
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1986
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1987 void
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1988 emit_strings(NMTBL *n)
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1989 {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1990 int l = emit_string_label();
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1991 int i;
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1992 for(i = n->dsp; i; i = cadr(i)) {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1993 ascii(scaddr(i));
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1994 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1995 emit_label(l);
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1996 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1997
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1998 void
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
1999 code_strings(int e2,int reg)
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2000 {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2001 int l = emit_string_label();
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2002 int i;
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2003 for(i = e2; i; i = cadr(i)) {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2004 ascii(scaddr(i));
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2005 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2006 if (output_mode==TEXT_EMIT_MODE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2007 printf(".text\n");
778
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2008 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2009 text_mode(0);
778
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2010 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2011 code_label_value(l,reg);
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2012 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 739
diff changeset
2013
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2014 #define MAX_COPY_LEN 20
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
2015 // #define MAX_COPY_LEN 10
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2016
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
2017 void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2018 emit_copy(int from,int to,int length,int offset,int value,int det)
917947ffeb7c power pc version
kono
parents:
diff changeset
2019 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2020 char *frn;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2021 char *trn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2022 char *drn;
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
2023 char *memmove = "memmove";
556
ef225b589888 s-dandy fix
kono
parents: 555
diff changeset
2024 int l;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2025 int dreg = get_register(); if (!dreg) error(-1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2026
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2027 drn = register_name(dreg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2028 use_int(from);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2029 use_int(to);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2030 frn = register_name(from);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2031 trn = register_name(to);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2032
917947ffeb7c power pc version
kono
parents:
diff changeset
2033 /* length <0 means upward direction copy */
917947ffeb7c power pc version
kono
parents:
diff changeset
2034 switch (length) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2035 case 0: break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2036 case 1: case -1:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2037 printf("\tlbz %s,%d(%s)\n",drn,offset,frn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2038 printf("\tstb %s,%d(%s)\n",drn,offset,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2039 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2040 case 2: case -2:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2041 printf("\tlhz %s,%d(%s)\n",drn,offset,frn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2042 printf("\tsth %s,%d(%s)\n",drn,offset,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2043 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2044 case 4: case -4:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2045 printf("\tlwz %s,%d(%s)\n",drn,offset,frn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2046 printf("\tstw %s,%d(%s)\n",drn,offset,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2047 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2048 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2049 if (length <0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2050 if (length >= -MAX_COPY_LEN) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2051 free_register(dreg); dreg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2052 for(;length<=-4;length+=4,offset-=4)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2053 emit_copy(from,to,-4,offset-4,0,det);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2054 for(;length<=-2;length+=2,offset-=2)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2055 emit_copy(from,to,-2,offset-2,0,det);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2056 if(length<0)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2057 emit_copy(from,to,length,offset-1,0,det);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2058 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2059 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2060 } else if (length <=MAX_COPY_LEN) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2061 free_register(dreg); dreg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2062 for(;length>=4;length-=4,offset+=4)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2063 emit_copy(from,to,4,offset,0,det);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2064 for(;length>=2;length-=2,offset+=2)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2065 emit_copy(from,to,2,offset,0,det);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2066 if(length>0)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2067 emit_copy(from,to,length,offset,0,det);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2068 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2069 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2070 clear_ptr_cache();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2071 code_save_stacks();
556
ef225b589888 s-dandy fix
kono
parents: 555
diff changeset
2072
ef225b589888 s-dandy fix
kono
parents: 555
diff changeset
2073 l = list3(3,0,to);
ef225b589888 s-dandy fix
kono
parents: 555
diff changeset
2074 l = list3(4,l,from);
ef225b589888 s-dandy fix
kono
parents: 555
diff changeset
2075 parallel_rassign(l);
ef225b589888 s-dandy fix
kono
parents: 555
diff changeset
2076
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2077 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2078 printf("\tli r5,%d\n",length>0?length:-length);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2079 /* offset should be ignored */
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
2080 /* overrap must be allowed */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2081 printf("\tbl L_%s$stub\n",memmove);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2082 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2083 printf("\tli 5,%d\n",length>0?length:-length);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2084 /* offset should be ignored */
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2085 /* overrap must be allowed */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2086 printf("\tbl %s\n",memmove);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2087 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2088 extern_define(memmove,0,FUNCTION,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2089 set_ireg(RET_REGISTER,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2090 //if (creg!=to) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2091 // free_register(to); to = creg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2092 //}
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2093 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2094 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2095 if (value) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2096 /* creg must point top of the destination data */
917947ffeb7c power pc version
kono
parents:
diff changeset
2097 /* this code is necessary for the value of assignment or function call */
917947ffeb7c power pc version
kono
parents:
diff changeset
2098 /* otherwise we don't need this */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2099 if(creg!=to) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2100 free_register(to);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2101 // set_ireg(to,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2102 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2103 }
583
421be86892b3 ia32 reorganization
kono
parents: 578
diff changeset
2104 if (dreg) free_register(dreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2105 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2106
917947ffeb7c power pc version
kono
parents:
diff changeset
2107 int
444
8bec605d1701 small sized struct
kono
parents: 440
diff changeset
2108 push_struct(int e4,int t,int arg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2109 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2110 int length,count;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2111 int dreg,sreg; char *drn,*crn,*srn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2112 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2113 if (!is_int_reg(creg)) error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2114 length=size(t);
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
2115 if(length%SIZE_OF_INT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2116 length += SIZE_OF_INT - (length%SIZE_OF_INT);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2117 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2118 dreg = get_register(); if (!dreg) error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2119 drn = register_name(dreg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2120 crn = register_name(creg);
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
2121 if (length<MAX_COPY_LEN) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2122 sreg = get_register(); if (!sreg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2123 srn = register_name(sreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2124 code_lvar(cadr(arg),dreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2125 for(count=0;count<length;count+=SIZE_OF_INT) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2126 printf("\tlwz %s,%d(%s)\n",srn,count,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2127 printf("\tstw %s,%d(%s)\n",srn,count,drn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2128 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2129 free_register(sreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2130 free_register(dreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2131 return length/SIZE_OF_INT;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2132 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2133 code_lvar(cadr(arg),dreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2134 /* downward direction copy */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2135 emit_copy(creg,dreg,length,0,0,1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2136 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2137 free_register(dreg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
2138 return length/SIZE_OF_INT;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2139 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2140
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2141 static void
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2142 set_ireg(int reg,int mode)
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2143 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2144 if (!is_int_reg(reg)) error(-1);
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2145 if (reg!=creg) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2146 clear_ptr_cache_reg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2147 if (ireg && reg!=ireg ) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2148 clear_ptr_cache_reg(ireg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2149 if (regs[ireg]!=REG_VAR) free_register(ireg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2150 if (mode) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2151 printf("\tmr %s,%s\n",register_name(reg),register_name(ireg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2152 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2153 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2154 if (regs[creg]!=REG_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2155 clear_ptr_cache_reg(creg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2156 free_register(creg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2157 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2158 if (creg==lreg) lreg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2159 regs[reg]=USING_REG;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2160 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2161 creg = ireg = reg;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2162 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2163
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2164 static void
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2165 set_freg(int reg,int mode)
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2166 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2167 if (!is_float_reg(reg)) error(-1);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2168 if (reg!=creg) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2169 if (freg && reg!=freg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2170 free_register(freg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2171 if (mode) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2172 printf("\tfmr %s,%s\n",fregister_name(reg),fregister_name(freg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2173 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2174 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2175 // if (creg!=ireg) free_register(creg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2176 regs[reg]=USING_REG;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2177 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2178 creg = freg = reg;
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2179 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2180
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2181 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2182 set_lreg(int reg,int mode)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2183 {
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
2184 if (reg==RET_LREGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2185 regv_l(reg) = RET_LREGISTER_L;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2186 regv_h(reg) = RET_LREGISTER_H;
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
2187 }
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2188 if (!is_longlong_reg(reg)) error(-1);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2189 if (reg!=creg) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2190 if (lreg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2191 if (reg!=lreg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2192 if (mode) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2193 printf("\tmr %s,%s\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2194 lregister_name_low(reg),lregister_name_low(lreg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2195 printf("\tmr %s,%s\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2196 lregister_name_high(reg),lregister_name_high(lreg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2197 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2198 free_register(lreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2199 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2200 if (lreg==creg) creg=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2201 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2202 if (creg) free_register(creg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2203 regs[reg]=USING_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2204 clear_ptr_cache_reg(regv_l(reg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2205 regs[regv_l(reg)]=USING_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2206 clear_ptr_cache_reg(regv_h(reg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2207 regs[regv_h(reg)]=USING_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2208 creg = lreg = reg;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2209 }
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2210 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2211
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2212 static void
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
2213 set_lreg_operand(int reg,int mode)
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
2214 {
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2215 // save_stack,clear_ptr_cache is assumed
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
2216 if (!is_longlong_reg(reg)) { error(-1); return; }
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
2217 if (mode) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2218 if (regv_l(reg)!=3)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2219 printf("\tmr %s,%s\n", register_name(3),lregister_name_high(reg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2220 if (regv_l(reg)!=4)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2221 printf("\tmr %s,%s\n", register_name(4),lregister_name_low(reg));
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
2222 }
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
2223 }
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
2224
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2225 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
2226 set_lreg_operand1(int reg,int mode)
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
2227 {
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2228 // save_stack,clear_ptr_cache is assumed
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
2229 if (!is_longlong_reg(reg)) { error(-1); return; }
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
2230 if (mode) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2231 if (regv_l(reg)!=5)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2232 printf("\tmr %s,%s\n", register_name(5),lregister_name_high(reg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2233 if (regv_l(reg)!=6)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2234 printf("\tmr %s,%s\n", register_name(6),lregister_name_low(reg));
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
2235 }
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
2236 }
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
2237
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2238 static void
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2239 use_reg(int arg)
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2240 {
468
464e7480395c *** empty log message ***
kono
parents: 467
diff changeset
2241 // printf("## use reg %d\n",arg);
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
2242 if (arg<0||arg> REAL_MAX_REGISTER+REAL_MAX_FREGISTER+ REAL_MAX_LREGISTER)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2243 error(-1);
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2244 clear_ptr_cache_reg(arg);
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2245 regs[arg]=USING_REG;
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2246 if (is_longlong_reg(arg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2247 clear_ptr_cache_reg(regv_l(arg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2248 regs[regv_l(arg)]=USING_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2249 clear_ptr_cache_reg(regv_h(arg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2250 regs[regv_h(arg)]=USING_REG;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2251 }
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2252 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2253
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2254 /*
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2255 store input argument into stack
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2256 we need this always because of one path compiler
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2257 */
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2258 static void
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
2259 code_save_input_registers(int dots)
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2260 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2261 int args;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2262 NMTBL *n;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2263 int reg;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2264 int tag;
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2265 // int lvar;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2266 int t;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2267 /* fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2268 int reg_offset = 0;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2269 int offset = 0;
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
2270 int reg_var = 0;
825
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2271 if (!parse_mode && dots) {
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2272 int stype = type; int smode = mode;
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2273 type = INT;
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2274 mode = LDECL;
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2275 stmode = 0;
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2276 // lsearch defines local name
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2277 NMTBL *n = def(lsearch("__my_va_list",0),0);
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2278 n->dsp = offset;
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2279 type = stype; mode = smode;
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2280 }
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 809
diff changeset
2281
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2282
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2283 for(args = fnptr->dsp;args;args = cadr(args)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2284 n = ncadddr(args);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2285 tag = n->sc;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2286 reg = n->dsp;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2287 if (!n||n==&null_nptr) error(REG_ERR);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2288 if (tag==REGISTER) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2289 n->dsp = offset;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2290 offset+=SIZE_OF_INT;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2291 t = INT;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2292 reg += reg_offset; /* for duplicated floating point argument */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2293 reg_var++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2294 } else if (tag==DREGISTER) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2295 n->dsp = offset;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2296 t = n->ty;
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2297 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2298 if(t==FLOAT) { offset+=SIZE_OF_FLOAT; reg_offset+=1; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2299 else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; reg_offset+=2; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2300 else error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2301 reg_var += 2;
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2302 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2303 if(t==FLOAT) { offset+=SIZE_OF_FLOAT; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2304 else if(t==DOUBLE) { offset+=SIZE_OF_DOUBLE; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2305 else error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2306 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2307 } else if (tag==LREGISTER) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2308 n->dsp = offset;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2309 t = n->ty;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2310 offset+=SIZE_OF_LONGLONG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2311 reg_offset+=2;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2312 reg_var += 2;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2313 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2314 // n->dsp = offset; this is no allowed becase of arg reorder
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2315 offset += size(n->ty);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2316 continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2317 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2318 n->sc = LVAR;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2319 g_expr_u(assign_expr0(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2320 list3n(LVAR,n->dsp,0),list3n(tag,reg,n),n->ty,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2321 if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2322 free_register(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2323 }
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2324 }
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
2325 if (dots) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2326 while ((reg = get_input_register_var(reg_var,0,0))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2327 g_expr_u(assign_expr0(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2328 list3n(LVAR,offset,0),reg,INT,INT));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2329 offset+=SIZE_OF_INT;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2330 reg_var++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2331 }
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
2332 #ifndef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2333 int skip = fwdlabel();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2334 int freg_var = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2335 printf("\tbne 1,%s%d\n",lpfx,skip);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2336 while ((reg = get_input_dregister_var(freg_var,0,0,1))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2337 g_expr_u(assign_expr0(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2338 list3n(LVAR,offset,0),reg,DOUBLE,DOUBLE));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2339 offset+=SIZE_OF_DOUBLE;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2340 freg_var++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2341 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2342 fwddef(skip);
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
2343 #endif
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
2344 }
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
2345 my_func_args = offset;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2346 }
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2347
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 445
diff changeset
2348 int
228
21b311266011 *** empty log message ***
kono
parents: 227
diff changeset
2349 not_simple_p(int e3)
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2350 {
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2351 switch (e3) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2352 case FUNCTION: case CONV: case LCALL: case STASS:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2353 case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2354 case LDIV: case LUDIV: case LMOD: case LUMOD: case LASSOP: case ALLOCA:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2355 case INLINE:
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2356 return 1;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2357 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2358 return 0;
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2359 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2360
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2361 static int
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2362 simple_arg(int e3)
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2363 {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2364 return !contains_p(e3,not_simple_p);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2365 }
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2366
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
2367 #define caller_arg_offset_v(arg) (ARG_LVAR_OFFSET+(arg)*SIZE_OF_INT)
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2368
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
2369 /*
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
2370 use input register as current register
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
2371 なんで、こんなに複雑なんだ?
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2372 むしろ、INPUT_REG みたいな mark をいれたら?
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
2373 */
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
2374
655
cddab906095e struct init in function arg (or other expression).
kono
parents: 649
diff changeset
2375 static void
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2376 use_input_reg(int reg,int mode)
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2377 {
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2378 if (is_int_reg(reg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2379 if (ireg&&reg == ireg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2380 if (creg==ireg) creg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2381 ireg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2382 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2383 if (lreg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2384 // free_regsiter(lreg) でいいんじゃないの?
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2385 if (regv_l(lreg)==reg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2386 regs[lreg]=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2387 if (regv_h(lreg)>reg&&regs[regv_h(lreg)]==USING_REG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2388 free_register(regv_h(lreg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2389 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2390 if (creg==lreg) creg = ireg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2391 free_register(lreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2392 lreg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2393 } else if (regv_h(lreg)==reg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2394 regs[lreg]=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2395 if (regv_h(lreg)>reg&&regs[regv_l(lreg)]==USING_REG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2396 free_register(regv_l(lreg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2397 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2398 if (creg==lreg) creg = ireg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2399 free_register(lreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2400 lreg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2401 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2402 }
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2403 } else if (is_longlong_reg(reg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2404 use_input_reg(regv_h(reg),mode);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2405 use_input_reg(regv_l(reg),mode);
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2406 } else if (is_float_reg(reg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2407 if (freg&&reg == freg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2408 if (creg==freg) creg = ireg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2409 freg = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2410 }
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2411 }
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2412 if (mode) use_reg(reg);
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2413 }
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
2414
271
e1a96bdbe527 MIPS continue...
kono
parents: 269
diff changeset
2415 static int
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2416 compute_complex_arg(int e3,int reg_arg_list,int arg) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2417 int t=caddr(e3);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2418 int e4 = car(e3);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2419 reg_arg_list = list2(arg,reg_arg_list);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2420 if (car(arg)==REGISTER||car(arg)==DREGISTER||
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2421 car(arg)==FREGISTER||car(arg)==LREGISTER)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2422 use_input_reg(cadr(arg),1);
709
8b54c40081de *** empty log message ***
kono
parents: 705
diff changeset
2423 g_expr_u(assign_expr0(arg,e4,t,t));
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2424 car(e3) = arg;
271
e1a96bdbe527 MIPS continue...
kono
parents: 269
diff changeset
2425 return reg_arg_list;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2426 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2427
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2428
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2429 #ifdef __APPLE__
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2430 static void
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2431 increment_function_arg(int e3,int *pnargs,int *preg_arg,int *pfreg_arg) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2432 int nargs=0,reg_arg=0,freg_arg=0;
487
b4d9809d6ee2 type attribute (half done)
kono
parents: 475
diff changeset
2433 int t=type_value(caddr(e3));
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
2434 if (t>=0&&(car(t)==BIT_FIELD)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2435 t = type_value(cadr(t));
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
2436 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2437 if(scalar(t)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2438 nargs ++ ; reg_arg++;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2439 } else if (t==LONGLONG||t==ULONGLONG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2440 nargs ++ ; reg_arg++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2441 nargs ++ ; reg_arg++;
475
ec4046c9d34f PowerPC float / int mix args bug fix.
kono
parents: 469
diff changeset
2442 } else if (t==FLOAT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2443 if (*preg_arg<MAX_INPUT_REGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2444 reg_arg += 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2445 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2446 freg_arg++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2447 nargs += size(t)/SIZE_OF_INT;
475
ec4046c9d34f PowerPC float / int mix args bug fix.
kono
parents: 469
diff changeset
2448 } else if (t==DOUBLE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2449 if (*preg_arg<MAX_INPUT_REGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2450 reg_arg += 2;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2451 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2452 nargs += size(t)/SIZE_OF_INT;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2453 freg_arg++;
638
35014112c01d multi dimentional array in functional arugments.
kono
parents: 637
diff changeset
2454 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2455 nargs += round4(size(t))/SIZE_OF_INT;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2456 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2457 error(TYERR);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2458 nargs ++ ;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2459 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2460 *pnargs += nargs;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2461 *preg_arg += reg_arg;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2462 *pfreg_arg += freg_arg;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2463 }
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2464 #else
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2465 static void
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2466 increment_function_arg(int e3,int *pnargs,int *preg_arg,int *pfreg_arg) {
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2467 int nargs=0,reg_arg=0,freg_arg=0;
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2468 int t=type_value(caddr(e3));
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2469 if (t>=0&&(car(t)==BIT_FIELD)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2470 t = type_value(cadr(t));
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2471 }
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2472 if(scalar(t)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2473 reg_arg++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2474 if (*preg_arg>=MAX_INPUT_REGISTER_VAR) nargs ++ ;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2475 } else if (t==LONGLONG||t==ULONGLONG) {
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2476 if (*preg_arg%2==1) reg_arg++; // alignment
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2477 if (*pnargs%2==1) nargs++; // alignment
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2478 reg_arg++; reg_arg++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2479 if (*preg_arg+1>=MAX_INPUT_REGISTER_VAR) nargs += 2;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2480 } else if (t==FLOAT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2481 freg_arg++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2482 if (*pfreg_arg>=MAX_INPUT_DREGISTER_VAR) nargs += size(t)/SIZE_OF_INT;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2483 } else if (t==DOUBLE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2484 freg_arg++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2485 if (*pfreg_arg>=MAX_INPUT_DREGISTER_VAR) nargs += round4(size(t))/SIZE_OF_INT;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2486 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2487 nargs += round4(size(t))/SIZE_OF_INT;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2488 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2489 error(TYERR);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2490 nargs ++ ;
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2491 }
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2492 *pnargs += nargs;
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2493 *preg_arg += reg_arg;
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2494 *pfreg_arg += freg_arg;
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2495 }
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2496 #endif
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2497
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2498 #define AS_SAVE 1
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2499 #define AS_ARG 0
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2500
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2501 /*
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2502 set storage type of caller's arguments
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2503 register or stack
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2504 this muse corprate with code_arg_register();
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2505 if AS_SAVE is set, register variable (or temporary local variable)
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2506 is used.
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2507 */
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
2508
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2509 static int
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2510 get_input_arg(int t,int mode,int nargs,int reg_arg,int freg_arg)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2511 {
487
b4d9809d6ee2 type attribute (half done)
kono
parents: 475
diff changeset
2512 t = type_value(t);
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
2513 if (t>=0&&(car(t)==BIT_FIELD)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2514 t = type_value(cadr(t));
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
2515 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2516 if(scalar(t)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2517 if (mode==AS_SAVE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2518 return get_register_var(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2519 } else if (reg_arg>=MAX_INPUT_REGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2520 return list3n(LVAR,caller_arg_offset_v(nargs),0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2521 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2522 int e = get_input_register_var(reg_arg,0,0);
843
6ae3a4f60798 powerpc register arg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
2523 clear_ptr_cache_reg(cadr(e));
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2524 return e;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2525 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2526 } else if (t==LONGLONG||t==ULONGLONG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2527 if (mode==AS_SAVE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2528 return get_lregister_var(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2529 } else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2530 return list3n(LVAR,caller_arg_offset_v(nargs),0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2531 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2532 int e = get_input_lregister_var(reg_arg,0,0);
843
6ae3a4f60798 powerpc register arg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
2533 clear_ptr_cache_reg(regv_l(cadr(e)));
6ae3a4f60798 powerpc register arg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
2534 clear_ptr_cache_reg(regv_h(cadr(e)));
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2535 return e;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2536 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2537 } else if (t==FLOAT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2538 if (mode==AS_SAVE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2539 return get_dregister_var(0,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2540 } else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2541 return list3n(LVAR,caller_arg_offset_v(nargs),0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2542 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2543 return get_input_dregister_var(freg_arg,0,0,0);
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2544 } else if (t==DOUBLE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2545 if (mode==AS_SAVE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2546 return get_dregister_var(0,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2547 } else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2548 return list3n(LVAR,caller_arg_offset_v(nargs),0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2549 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2550 return get_input_dregister_var(freg_arg,0,0,1);
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2551 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2552 if (mode==AS_SAVE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2553 return get_register_var(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2554 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2555 return list3n(LVAR,caller_arg_offset_v(nargs),0);
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2556 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2557 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2558 return get_register_var(0);
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2559 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2560 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2561
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2562 int
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2563 function(int e1)
917947ffeb7c power pc version
kono
parents:
diff changeset
2564 {
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2565 int e2,e3,e4,e5,nargs,t,r0;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2566 int arg,reg_arg,freg_arg,arg_assign;
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
2567 int dots;
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2568 int reg_arg_list=0,ret_type,special_lvar;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2569 NMTBL *fn = 0;
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2570 int jmp = 0;
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2571 char *jrn;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2572 int complex_;
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
2573 int pnargs=0,preg_arg=0,pfreg_arg=0;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2574 int stargs;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2575
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2576 special_lvar = -1;
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 304
diff changeset
2577 ret_type = function_type(cadddr(e1),&dots);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2578 if (caddr(cadddr(e1))==0) dots=1;
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2579
285
912b54949344 register assop const ( int/long )
kono
parents: 283
diff changeset
2580 arg_assign = 0;
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2581 e2 = cadr(e1);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2582 if (car(e2) == FNAME) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2583 fn=ncaddr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2584 } else {
285
912b54949344 register assop const ( int/long )
kono
parents: 283
diff changeset
2585 if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2586 jmp = get_register_var(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2587 if (car(jmp)!=REGISTER) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2588 reg_arg_list = list2(jmp,reg_arg_list);
285
912b54949344 register assop const ( int/long )
kono
parents: 283
diff changeset
2589 if (!simple_arg(e2)) {
912b54949344 register assop const ( int/long )
kono
parents: 283
diff changeset
2590 g_expr_u(assign_expr0(jmp,e2,INT,INT));
912b54949344 register assop const ( int/long )
kono
parents: 283
diff changeset
2591 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2592 arg_assign = list2(assign_expr0(jmp,e2,INT,INT),arg_assign);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2593 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2594 /* first we execute complex argument to avoid interaction with
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2595 input variables */
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2596 stargs = 0;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2597 complex_ = 0;
259
18837238e306 complex argument pre-calcuration done for power pc
kono
parents: 258
diff changeset
2598 nargs = reg_arg = freg_arg = 0;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2599 for (e3 = e1 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2600 t=caddr(e3);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2601 if ((e5= !simple_arg(car(e3)))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2602 if (complex_) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2603 arg = get_input_arg(caddr(complex_),AS_SAVE,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2604 pnargs,preg_arg,pfreg_arg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2605 reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2606 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2607 pnargs=nargs;preg_arg=reg_arg;pfreg_arg=freg_arg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2608 complex_ = e3;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2609 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2610 if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2611 // The struct should be pushed after complex arguments.
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2612 if (e5) { // compute address only, complex_ is me now. Clear it.
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2613 complex_ = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2614 e4 = car(e3);
901
8bdd5061cb8f RSTRUCT removal (at last)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
2615 if (car(e4)==INDIRECT) e4 = cadr(e4);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2616 if (!simple_arg(e4)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2617 // Calculate complex struct address here.
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2618 // If simple, leave it.
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2619 arg = get_register_var(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2620 g_expr_u(assign_expr0(arg,e4,INT,INT));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2621 car(e3)=arg;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2622 reg_arg_list = list2(arg,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2623 if (car(arg)==REGISTER) use_input_reg(cadr(arg),1);
408
b4375f895fd5 ARM struct copy, alloca fix
kono
parents: 405
diff changeset
2624 else car(e3) = rvalue_t(arg,INT);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2625 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2626 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2627 stargs = list4(e3,stargs,nargs,reg_arg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2628 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2629 increment_function_arg(e3,&nargs,&reg_arg,&freg_arg);
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2630 }
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2631
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2632 /* now all input register vars are free */
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2633 code_save_stacks();
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
2634 // set_lreg(LREG_LREGISTER,0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2635 set_freg(FREG_FREGISTER,0);
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
2636 set_ireg(CREG_REGISTER,0);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2637
268
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2638 // Struct arguments need emit_copy. it destructs 3 input registers.
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2639 // But it returns no value on a register. So calculate it here.
268
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2640 // We cannot do this in the previous loop, because the copied struct may be
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2641 // override by other complex arguments. But before this we have to check
268
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2642 // complex_.
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2643
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2644 if (stargs) {
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2645 if (complex_) {
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2646 arg = get_input_arg(caddr(complex_),AS_SAVE,
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2647 pnargs,preg_arg,pfreg_arg);
271
e1a96bdbe527 MIPS continue...
kono
parents: 269
diff changeset
2648 reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
268
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2649 }
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2650 for(stargs=reverse0(stargs);stargs;stargs = cadr(stargs)) {
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2651 e3 = car(stargs);
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2652 e4 = car(e3);
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2653 t = caddr(e3);
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2654 arg = get_input_arg(t,AS_ARG,caddr(stargs),cadddr(stargs),0);
444
8bec605d1701 small sized struct
kono
parents: 440
diff changeset
2655 push_struct(e4,t,arg);
268
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2656 car(e3)=0; // done
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2657 }
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2658 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2659 // last complex argument can use input register
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2660 if (complex_) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2661 arg = get_input_arg(caddr(complex_),AS_ARG,pnargs,preg_arg,pfreg_arg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2662 reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2663 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2664 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2665
285
912b54949344 register assop const ( int/long )
kono
parents: 283
diff changeset
2666 nargs = reg_arg = freg_arg = 0;
268
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2667 // calc stack arguments first, it may requires extra registers,
3a368fc37559 MIPS binary continue...
kono
parents: 263
diff changeset
2668 // and we can still use input registers now.
259
18837238e306 complex argument pre-calcuration done for power pc
kono
parents: 258
diff changeset
2669 for (e3 = e1; e3;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2670 increment_function_arg(e3,&nargs,&reg_arg,&freg_arg),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2671 e3 = cadr(e3)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2672 if (!(e4=car(e3))) continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2673 t=caddr(e3);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2674 arg = get_input_arg(t,AS_ARG,nargs,reg_arg,freg_arg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2675 if (car(arg)!=LVAR) continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2676 g_expr_u(assign_expr0(arg,e4,t,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2677 if (t==LONGLONG||t==ULONGLONG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2678 if (reg_arg+1==MAX_INPUT_REGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2679 // half register, half memory case
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2680 arg_assign = list2(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2681 assign_expr0(r0=get_input_register_var(reg_arg,0,0),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2682 arg,INT,INT),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2683 arg_assign);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2684 use_input_reg(cadr(r0),1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2685 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2686 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2687 car(e3)=0; // done
259
18837238e306 complex argument pre-calcuration done for power pc
kono
parents: 258
diff changeset
2688 }
18837238e306 complex argument pre-calcuration done for power pc
kono
parents: 258
diff changeset
2689 nargs = reg_arg = freg_arg = 0;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 257
diff changeset
2690 for (e3 = e1; e3;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2691 increment_function_arg(e3,&nargs,&reg_arg,&freg_arg),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2692 e3 = cadr(e3)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2693 if (!(e4=car(e3))) continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2694 t=type_value(caddr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2695 arg = get_input_arg(t,AS_ARG,nargs,reg_arg,freg_arg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2696 if(scalar(t)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2697 reg_arg_list = list2(arg,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2698 /* protect from input register free */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2699 if (car(arg)==REGISTER) {
843
6ae3a4f60798 powerpc register arg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
2700 set_ireg(cadr(arg),0);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2701 g_expr_u(assign_expr0(arg,e4,t,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2702 use_input_reg(cadr(arg),1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2703 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2704 g_expr_u(assign_expr0(arg,e4,t,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2705 } else if (t==LONGLONG||t==ULONGLONG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2706 if (reg_arg+1==MAX_INPUT_REGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2707 // half register, half memory case
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2708 // put whole long long anyway
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2709 arg_assign = list2(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2710 assign_expr0(r0=get_input_register_var(reg_arg,0,0),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2711 arg,INT,INT),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2712 arg_assign);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2713 use_input_reg(cadr(r0),1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2714 reg_arg_list = list2(r0,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2715 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2716 if (car(arg)==LREGISTER) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2717 use_input_reg(cadr(arg),1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2718 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2719 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2720 reg_arg_list = list2(arg,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2721 g_expr_u(assign_expr0(arg,e4,t,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2722 } else if (t==DOUBLE||t==FLOAT) {
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2723 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2724 if (reg_arg<MAX_INPUT_REGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2725 /* sigh...
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2726 printf requires floating value in integer registers
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2727 */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2728 if (dots) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2729 int r1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2730 if (car(e4)==DRLVAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2731 special_lvar = cadr(e4);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2732 e5 = list3n(LVAR,special_lvar,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2733 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2734 special_lvar = new_lvar(SIZE_OF_DOUBLE);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2735 g_expr(assign_expr0(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2736 (e5=list3n(LVAR,special_lvar,0)),e4,DOUBLE,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2737 reg_arg_list = list2(e5,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2738 e4 = list2(DREGISTER,freg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2739 /* freg should not change until XXX */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2740 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2741 r0=get_input_register_var(reg_arg,0,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2742 r1 = reg_arg+1+MIN_TMP_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2743 if (regs[r1]==PTRC_REG)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2744 clear_ptr_cache_reg(list2(REGISTER,r1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2745 /* else if (regs[r1]) error(-1); */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2746 r1=get_input_register_var_1(reg_arg+1,0,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2747 use_input_reg(cadr(r0),1); /* protect from input register free */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2748 use_input_reg(cadr(r1),1); /* protect from input register free */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2749 reg_arg_list = list2(r0,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2750 reg_arg_list = list2(r1,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2751 arg_assign = list2( assign_expr0(r0,e5,INT,INT), arg_assign);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2752 arg_assign = list2( assign_expr0(r1,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2753 list3n(LVAR,special_lvar+SIZE_OF_INT,0),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2754 INT,INT), arg_assign);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2755 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2756 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2757 if (dots && (freg_arg*8+reg_arg*4)>=32 && freg_arg<MAX_INPUT_DREGISTER_VAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2758 /*
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2759 it requires integer register and floating register and
496
5640fb7a270d more bugs...
kono
parents: 495
diff changeset
2760 stack value.
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2761 */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2762 arg_assign = list2(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2763 assign_expr0(list3n(LVAR,caller_arg_offset_v(nargs),0),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2764 get_input_dregister_var(freg_arg,0,0,1),t,t),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2765 arg_assign);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2766 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2767 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2768 reg_arg_list = list2(arg,reg_arg_list);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2769 if (car(arg)==DREGISTER) {
845
a97cd8b97434 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 844
diff changeset
2770 set_freg(cadr(arg),0);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2771 g_expr_u(assign_expr0(arg,e4,t,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2772 use_input_reg(cadr(arg),1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2773 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2774 g_expr_u(assign_expr0(arg,e4,t,t));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2775 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2776 // structs are finished
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2777 }
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2778 if (max_func_args<nargs) max_func_args=nargs;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2779 for(;arg_assign;arg_assign=cadr(arg_assign)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2780 g_expr_u(car(arg_assign));
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2781 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2782 clear_ptr_cache();
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2783 #ifndef __APPLE__
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
2784 if (dots) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2785 if (freg_arg) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2786 // variadic function has floating value in register
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2787 printf("\tcreqv 6,6,6\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2788 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2789 // printf("\tcrxor 6,6,6\n"); // for value in stack
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2790 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2791 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2792 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2793 if (car(e2) == FNAME) {
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2794 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2795 printf("\tbl\tL_%s$stub\n",fn->nm);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2796 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2797 printf("\tbl\t%s\n",fn->nm);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2798 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2799 } else {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2800 jrn = register_name(cadr(jmp));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2801 printf("\tmtctr %s\n",jrn);
917947ffeb7c power pc version
kono
parents:
diff changeset
2802 printf("\tbctrl\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
2803 }
716
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
2804 free_register_var(reg_arg_list);
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2805 if (ret_type==DOUBLE||ret_type==FLOAT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2806 set_freg(RET_FREGISTER,0);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2807 } else if (ret_type==ULONGLONG||ret_type==LONGLONG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2808 set_lreg(RET_LREGISTER,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2809 use_reg(RET_LREGISTER);
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2810 } else if (ret_type==VOID) {
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2811 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2812 set_ireg(RET_REGISTER,0);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2813 }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
2814 cleanup_lregister0();
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2815 return ret_type;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2816 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2817
917947ffeb7c power pc version
kono
parents:
diff changeset
2818 void
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2819 code_alloca(int e1,int reg)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2820 {
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2821 char *crn,*grn;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2822 int g;
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2823
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2824 if (!is_const(e1)) {
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2825 g_expr(list3(BAND,list3(ADD,e1,list2(CONST,15)),list2(CONST,~15)));
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2826 use_int(reg);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2827 } else {
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2828 use_int(reg);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2829 code_const(round16(cadr(e1)),reg);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2830 }
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2831 use_int(reg);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2832 g = get_register();
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2833 crn = register_name(reg);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2834 grn = register_name(g);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2835 // printf("\trlwinm r0,%s,0,0,27\n",crn);
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2836 #ifdef R1SAVE
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2837 printf("\tlwz %s,0(%s)\n",grn,register_name(1));
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2838 printf("\tneg %s,%s\n",crn,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2839 printf("\tstwux %s,%s,%s\n",grn,register_name(1),crn);
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2840 #else
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2841 printf("\tlwz %s,0(%s)\n",grn,register_name(1));
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2842 printf("\tneg %s,%s\n",crn,crn);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2843 printf("\tstwux %s,%s,%s\n",grn,register_name(1),crn);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
2844 #endif
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2845 // printf("\tstw %s,0(r1)\n",grn);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2846 if (!max_func_arg_label) max_func_arg_label = fwdlabel();
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2847 #ifdef __APPLE__
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2848 printf("\taddis r1,r1,ha16(L_%d)\n",max_func_arg_label);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2849 printf("\taddi %s,r1,lo16(L_%d)\n",crn,max_func_arg_label);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2850 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2851 printf("\taddis 1,1,.LC%d@ha\n",max_func_arg_label);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2852 printf("\taddi %s,1,.LC%d@l\n",crn,max_func_arg_label);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2853 #endif
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2854 free_register(g);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2855 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2856
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 308
diff changeset
2857 void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2858 code_frame_pointer(int e3) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2859 use_int(e3);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2860 #if R1SAVE
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2861 printf("\tmr %s,%s\n",register_name(1),register_name(e3));
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2862 #else
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
2863 printf("\tmr %s,%s\n",register_name(REG_fp),register_name(e3));
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2864 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2865 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2866
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
2867 int
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
2868 code_frame_pointer_register()
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
2869 {
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
2870 return list2(REGISTER,REG_fp);
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
2871 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2872
917947ffeb7c power pc version
kono
parents:
diff changeset
2873 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2874 code_fix_frame_pointer(int disp_offset) {
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
2875 #if 0
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2876 printf("\tla r30,");
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
2877 printf("lo16(%d)(r30)\n",FUNC_LVAR(0)-CODE_LVAR(0));
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 577
diff changeset
2878 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2879 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2880
917947ffeb7c power pc version
kono
parents:
diff changeset
2881 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2882 code_jmp(char *s) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2883 max_reg_var = REG_VAR_BASE-REG_VAR_MIN;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2884 max_freg_var = FREG_VAR_BASE-FREG_VAR_MIN;
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2885 #ifdef __APPLE__
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2886 printf("\tb L_%s$stub\n",s);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2887 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2888 printf("\tb %s\n",s);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2889 #endif
283
230a3b98b843 MIPS jump work.
kono
parents: 280
diff changeset
2890 control=0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2891 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2892
917947ffeb7c power pc version
kono
parents:
diff changeset
2893
917947ffeb7c power pc version
kono
parents:
diff changeset
2894 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2895 code_indirect_jmp(int e2) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2896 max_reg_var = REG_VAR_BASE-REG_VAR_MIN;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2897 max_freg_var = FREG_VAR_BASE-FREG_VAR_MIN;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2898 use_int(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2899 printf("\tmtctr %s\n",register_name(e2));
917947ffeb7c power pc version
kono
parents:
diff changeset
2900 printf("\tbctr\n");
283
230a3b98b843 MIPS jump work.
kono
parents: 280
diff changeset
2901 control=0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2902 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2903
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2904 static void
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2905 code_add_op(char *op, char *crn, int offset, char *rrn)
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2906 {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2907 #ifdef __APPLE__
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2908 if (LARGE_OFFSET(offset)) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2909 printf("\taddis %s,%s,ha16(%d)\n",crn,crn,offset);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2910 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
2911 printf("\t%s %s,lo16(%d)(%s)\n",op,crn,offset,rrn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2912 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2913 if (LARGE_OFFSET(offset)) {
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2914 printf("\taddis %s,%s,%d@ha\n",crn,crn,offset);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2915 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
2916 printf("\t%s %s,%d@l(%s)\n",op,crn,offset,rrn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2917 #endif
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2918 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2919
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2920 void
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2921 code_rindirect(int e1, int reg,int offset, int sign,int sz)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2922 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2923 char *crn,*rrn;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2924 g_expr(e1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2925 if (!is_int_reg(creg)) error(-1);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2926 crn=register_name(creg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2927 use_int(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2928 rrn=register_name(reg);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2929 code_add_op(cload(sz),rrn,offset,crn);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2930 cext(sign,sz,reg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2931 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2932
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2933 #if FLOAT_CODE
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2934 int
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2935 code_drindirect(int e1, int reg,int offset, int d)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2936 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2937 char *crn;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2938 g_expr(e1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2939 if (!is_int_reg(creg)) error(-1);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2940 crn=register_name(creg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2941 use_float(d,reg);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2942 code_add_op(fload(d),fregister_name(reg),offset,crn);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
2943
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2944 return d?DOUBLE:FLOAT;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2945 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2946 #endif
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2947
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
2948 #if LONGLONG_CODE
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2949
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2950
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2951 static void
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2952 lload(int creg,int reg,int offset)
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2953 {
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2954 char *crn = register_name(creg);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2955 #ifdef __APPLE__
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
2956 if (LARGE_OFFSET(offset)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2957 printf("\taddis %s,%s,ha16(%d)\n",crn,crn,offset);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
2958 }
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2959 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2960 if (creg!=regv_l(reg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2961 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2962 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset+SIZE_OF_INT,crn);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2963 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2964 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset+SIZE_OF_INT,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2965 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset,crn);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2966 }
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2967 #else
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2968 if (creg!=regv_h(reg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2969 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2970 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset+SIZE_OF_INT,crn);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2971 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2972 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset+SIZE_OF_INT,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2973 printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset,crn);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2974 }
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2975 #endif
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2976 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2977 if (LARGE_OFFSET(offset)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2978 printf("\taddis %s,%s,%d@ha\n",crn,crn,offset);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2979 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2980 #if ENDIAN_L==0
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2981 if (creg!=regv_l(reg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2982 printf("\tlwz %s,%d@l(%s)\n",lregister_name_low(reg),offset,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2983 printf("\tlwz %s,%d@l(%s)\n",lregister_name_high(reg),offset+SIZE_OF_INT,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2984 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2985 printf("\tlwz %s,%d@l(%s)\n",lregister_name_high(reg),offset+SIZE_OF_INT,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2986 printf("\tlwz %s,%d@l(%s)\n",lregister_name_low(reg),offset,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2987 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2988 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2989 if (creg!=regv_h(reg)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2990 printf("\tlwz %s,%d@l(%s)\n",lregister_name_high(reg),offset,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2991 printf("\tlwz %s,%d@l(%s)\n",lregister_name_low(reg),offset+SIZE_OF_INT,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2992 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2993 printf("\tlwz %s,%d@l(%s)\n",lregister_name_low(reg),offset+SIZE_OF_INT,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
2994 printf("\tlwz %s,%d@l(%s)\n",lregister_name_high(reg),offset,crn);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2995 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2996 #endif
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2997
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
2998 #endif
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
2999 }
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
3000
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
3001 int
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3002 code_lrindirect(int e1, int reg, int offset, int us)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
3003 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
3004 char *crn;
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
3005 int creg0;
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
3006
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
3007 g_expr(e1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3008 if (!is_int_reg(creg)) error(-1);
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
3009 crn=register_name(creg0=creg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3010 use_longlong(reg);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
3011 lload(creg0,reg,offset);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3012 return us?ULONGLONG:LONGLONG;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
3013 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
3014 #endif
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
3015
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3016 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3017 code_assign_gvar(int e2,int creg,int byte) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3018 use_int(creg);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3019 code_ldf(cstore(byte),register_name(creg),cadr(e2),
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3020 get_ptr_cache(ncaddr(e2)));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3021 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3022
917947ffeb7c power pc version
kono
parents:
diff changeset
3023 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3024 code_assign_lvar(int e2,int creg,int byte) {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
3025 char *crn;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3026 use_int(creg);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
3027 crn=register_name(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
3028 lvar_intro(e2);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3029 printf("\t%s %s,",cstore(byte),crn);
165
kono
parents: 164
diff changeset
3030 lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3031 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3032
917947ffeb7c power pc version
kono
parents:
diff changeset
3033 void
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
3034 code_assign_register(int e2,int byte,int creg) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3035 use_int(creg);
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
3036 if (e2!=creg)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3037 printf("\tmr %s,%s\n",register_name(e2),register_name(creg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3038 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3039
917947ffeb7c power pc version
kono
parents:
diff changeset
3040 void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
3041 code_assign(int e2,int byte,int creg) {
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
3042 char *drn;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3043 char *crn;
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
3044 use_int(e2);
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
3045 drn=register_name(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3046 use_int(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3047 crn=register_name(creg);
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3048
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3049 printf("\t%s %s,0(%s)\n",cstore(byte),crn,drn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3050 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3051
917947ffeb7c power pc version
kono
parents:
diff changeset
3052
917947ffeb7c power pc version
kono
parents:
diff changeset
3053 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3054 code_register_assop(int e2,int reg, int op,int byte) {
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3055 // reg <= reg(e2) op=reg
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3056 use_int(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3057 tosop(op,e2,reg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3058 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3059
917947ffeb7c power pc version
kono
parents:
diff changeset
3060 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3061 code_assop(int op,int creg, int byte,int sign) {
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3062 int xreg;
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3063 // (*pop()) op = creg
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3064 // creg should be ecx
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3065
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3066 use_int(creg);
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3067 xreg = emit_pop(0); /* pop e3 value */
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3068 emit_push();
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3069 ld_indexx(byte,0,creg,ireg,sign);
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3070 tosop(op,ireg,xreg);
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3071 emit_pop_free(xreg);
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3072 xreg = emit_pop(0); /* pop e3 value */
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3073 printf("\t%s %s,0(%s)\n",cstore(byte),
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3074 register_name(ireg),register_name(xreg));
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3075 emit_pop_free(xreg);
594
f49c825920c4 tosop optimize buf fix
kono
parents: 593
diff changeset
3076 }
f49c825920c4 tosop optimize buf fix
kono
parents: 593
diff changeset
3077
f49c825920c4 tosop optimize buf fix
kono
parents: 593
diff changeset
3078 int
f49c825920c4 tosop optimize buf fix
kono
parents: 593
diff changeset
3079 tosop_operand_safe_p(int op)
f49c825920c4 tosop optimize buf fix
kono
parents: 593
diff changeset
3080 {
f49c825920c4 tosop optimize buf fix
kono
parents: 593
diff changeset
3081 return 1;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3082 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3083
917947ffeb7c power pc version
kono
parents:
diff changeset
3084 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3085 tosop(int op,int creg,int oreg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3086 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3087 int dx = -1;
252
1452eb0eab20 *** empty log message ***
kono
parents: 246
diff changeset
3088 int ox = -1;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3089 char *orn,*crn,*drn;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3090 // creg = creg op oreg
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3091
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3092 use_int(creg);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3093 if(oreg==-1) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3094 error(-1);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3095 } else if (oreg<= -REG_LVAR_OFFSET) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3096 ox = get_register(); if (ox<0) error(-1);
252
1452eb0eab20 *** empty log message ***
kono
parents: 246
diff changeset
3097 code_rlvar(oreg+REG_LVAR_OFFSET,ox);
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
3098 free_lvar(oreg+REG_LVAR_OFFSET);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3099 oreg = ox;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3100 }
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3101
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3102 switch(op) {
917947ffeb7c power pc version
kono
parents:
diff changeset
3103 case LSHIFT:
917947ffeb7c power pc version
kono
parents:
diff changeset
3104 case ULSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3105 shift("slw",creg,oreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3106 if(ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3107 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3108 case RSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3109 shift("sraw",creg,oreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3110 if(ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3111 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3112 case URSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3113 shift("srw",creg,oreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3114 if(ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3115 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3116 }
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
3117 orn = register_name(oreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3118 crn = register_name(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
3119 switch(op) {
917947ffeb7c power pc version
kono
parents:
diff changeset
3120 case ADD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3121 printf("\tadd %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3122 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3123 case SUB:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3124 printf("\tsub %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3125 break;
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
3126 case CMP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3127 inc_cmpflag();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3128 printf("\tcmpw %s,%s,%s\n",crname(cmpflag),crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3129 break;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
3130 case UCMP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3131 inc_cmpflag();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3132 printf("\tcmplw %s,%s,%s\n",crname(cmpflag),crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3133 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3134 case BAND:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3135 printf("\tand %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3136 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3137 case EOR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3138 printf("\txor %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3139 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3140 case BOR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3141 printf("\tor %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3142 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3143 case MUL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3144 printf("\tmullw %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3145 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3146 case UMUL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3147 printf("\tmullw %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3148 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3149 case DIV:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3150 printf("\tdivw %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3151 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3152 case UDIV:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3153 printf("\tdivwu %s,%s,%s\n",crn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3154 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3155 case MOD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3156 dx=get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3157 drn = register_name(dx);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3158 printf("\tdivw %s,%s,%s\n",drn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3159 printf("\tmullw %s,%s,%s\n",drn,drn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3160 printf("\tsubf %s,%s,%s\n",crn,drn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3161 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3162 case UMOD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3163 dx=get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3164 drn = register_name(dx);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3165 printf("\tdivwu %s,%s,%s\n",drn,crn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3166 printf("\tmullw %s,%s,%s\n",drn,drn,orn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3167 printf("\tsubf %s,%s,%s\n",crn,drn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3168 break;
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
3169 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3170 error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3171 }
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3172 if(dx!=-1) free_register(dx);
252
1452eb0eab20 *** empty log message ***
kono
parents: 246
diff changeset
3173 if(ox!=-1) free_register(ox);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3174 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3175
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3176 int
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3177 code_const_op_p(int op,int v)
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3178 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3179 if (car(v)!=CONST) return 0;
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
3180 if (op==DIV||op==UDIV) return ilog(v);
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
3181 if (op==BAND||op==MOD||op==UMOD) return 0;
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3182 v = cadr(v);
214
4f459364c334 *** empty log message ***
kono
parents: 213
diff changeset
3183 return (-32766<v&&v<32767);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3184 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3185
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
3186 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3187 oprtc(int op,int creg, int v)
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3188 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3189 char *crn;
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
3190 int l;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3191 use_int(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3192 crn = register_name(creg);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3193 v = cadr(v);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3194
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3195 switch(op) {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3196 case LSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3197 case ULSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3198 printf("\tslwi %s,%s,%d\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3199 return;
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
3200 case DIV:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3201 v = ilog(v);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3202 case RSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3203 printf("\tsrawi %s,%s,%d\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3204 return;
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
3205 case UDIV:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3206 v = ilog(v);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3207 case URSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3208 printf("\tsrwi %s,%s,%d\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3209 return;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3210 case ADD:
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3211 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3212 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,v);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3213 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3214 printf("\taddi %s,%s,%d@l\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3215 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3216 break;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3217 case SUB:
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3218 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3219 printf("\taddi %s,%s,lo16(-%d)\n",crn,crn,v);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3220 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3221 printf("\taddi %s,%s,-%d@l\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3222 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3223 break;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3224 case CMP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3225 inc_cmpflag();
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3226 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3227 printf("\tcmpwi %s,%s,lo16(%d)\n",crname(cmpflag),crn,v);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3228 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3229 printf("\tcmpwi %s,%s,%d@l\n",crname(cmpflag),crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3230 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3231 break;
354
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
3232 case UCMP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3233 inc_cmpflag();
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3234 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3235 printf("\tcmplwi %s,%s,lo16(%d)\n",crname(cmpflag),crn,v);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3236 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3237 printf("\tcmplwi %s,%s,%d@l\n",crname(cmpflag),crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3238 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3239 break;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3240 case EOR:
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3241 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3242 printf("\txori %s,%s,lo16(%d)\n",crn,crn,v);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3243 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3244 printf("\txori %s,%s,%d@l\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3245 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3246 break;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3247 case BOR:
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3248 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3249 printf("\tori %s,%s,lo16(%d)\n",crn,crn,v);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3250 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3251 printf("\tori %s,%s,%d@l\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3252 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3253 break;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3254 case MUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3255 case UMUL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3256 if ((l=ilog(v))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3257 printf("\tslwi %s,%s,%d\n",crn,crn,l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3258 } else
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3259 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3260 printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3261 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3262 printf("\tmulli %s,%s,%d@l\n",crn,crn,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3263 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3264 break;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3265 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3266 error(-1);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3267 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
3268 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3269
917947ffeb7c power pc version
kono
parents:
diff changeset
3270 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3271 shift(char *op, int creg, int reg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3272 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3273 char *crn;
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
3274 char *rrn = register_name(reg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3275 use_int(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3276 crn = register_name(creg);
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
3277 printf("\t%s %s,%s,%s\n",op,crn,crn,rrn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3278 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3279
917947ffeb7c power pc version
kono
parents:
diff changeset
3280 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3281 ld_indexx(int byte, int n, int xreg,int creg, int sign)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3282 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3283 char *crn;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3284 use_int(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
3285 crn = register_name(creg);
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
3286 printf("\t%s %s,%d(%s)\n",cload(byte),register_name(creg),n,
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3287 register_name(xreg));
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
3288 cext(sign,byte,creg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3289 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3290
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3291 int
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3292 code_csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3293 {
458
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
3294 return glist2(REGISTER,creg);
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3295 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3296
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3297 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
3298 code_cmpdimm(int e, int csreg,int label,int cond)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3299 {
415
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3300 int reg,regsv;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3301 /* used in dosiwtch() */
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3302 inc_cmpflag();
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3303 if (-32767<e&&e<32767) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3304 printf("\tcmpwi %s,%s,%d\n",crname(cmpflag),register_name(csreg),e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3305 jcond(label,cond);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3306 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3307 regsv = regs[csreg]; regs[csreg]=USING_REG;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3308 reg = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3309 regs[csreg]= regsv;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3310 code_const(e,reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3311 printf("\tcmpw %s,%s,%s\n",crname(cmpflag),register_name(csreg),register_name(reg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3312 jcond(label,cond);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3313 free_register(reg);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3314 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3315 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3316
917947ffeb7c power pc version
kono
parents:
diff changeset
3317 void
917947ffeb7c power pc version
kono
parents:
diff changeset
3318 code_opening(char *filename)
917947ffeb7c power pc version
kono
parents:
diff changeset
3319 {
917947ffeb7c power pc version
kono
parents:
diff changeset
3320 printf("\t.file \"%s\"\n",filename);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3321 /* printf("\t.version\t\"01.01\"\n"); */
804
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3322 printf("cbc_compiled.:\n");
605
1078c7e3bfb0 minor fixes
kono
parents: 603
diff changeset
3323 // printf(".text\n");
804
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3324 #ifndef __APPLE__
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3325 printf(
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3326 " .set r0,0\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3327 " .set r1,1\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3328 " .set r2,2\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3329 " .set r3,3\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3330 " .set r4,4\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3331 " .set r5,5\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3332 " .set r6,6\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3333 " .set r7,7\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3334 " .set r8,8\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3335 " .set r9,9\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3336 " .set r10,10\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3337 " .set r11,11\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3338 " .set r12,12\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3339 " .set r13,13\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3340 " .set r14,14\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3341 " .set r15,15\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3342 " .set r16,16\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3343 " .set r17,17\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3344 " .set r18,18\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3345 " .set r19,19\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3346 " .set r20,20\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3347 " .set r21,21\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3348 " .set r22,22\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3349 " .set r23,23\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3350 " .set r24,24\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3351 " .set r25,25\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3352 " .set r26,26\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3353 " .set r27,27\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3354 " .set r28,28\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3355 " .set r29,29\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3356 " .set r30,30\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3357 " .set r31,31\n"
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3358 );
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3359 #endif
aec31f182f9f PS3 PPU register
kono@localhost.localdomain
parents: 803
diff changeset
3360
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3361 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3362
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3363 #define CRBITSIZ 4
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3364
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3365 static int
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3366 rexpr_bool(int e1,int reg)
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3367 {
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3368 int t,flag=-1,eq=-1,neg=-1;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3369 char *rn;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3370 switch(car(e1)) {
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3371 case GT: t=INT; flag = 2; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3372 case UGT: t=0; flag = 2; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3373 case GE: t=INT; flag = 2; eq=3; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3374 case UGE: t=0; flag = 2; eq=3; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3375 case LT: t=INT; flag = 1; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3376 case ULT: t=0; flag = 1; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3377 case LE: t=INT; flag = 1; eq=3; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3378 case ULE: t=0; flag = 1; eq=3; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3379 case EQ: t=INT; flag = 3; break;
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
3380 case NEQ: t=INT; flag = 3; neg=3; break;
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3381 default: return 0;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3382 }
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3383 g_expr(list3((t==INT?CMP:UCMP),cadr(e1),caddr(e1)));
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3384 use_int(reg);
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3385 rn = register_name(reg);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
3386 t = CRBITSIZ*cmpflag;
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3387 if (eq>0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3388 printf("\tcror %d,%d,%d\n",t+flag-1,t+eq-1,t+flag-1);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
3389 }
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
3390 if (neg>0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3391 neg = t+neg-1,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3392 printf("\tcrnor %d,%d,%d\n",neg,neg,neg);
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3393 }
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3394 printf("\tmfcr %s\n",rn);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
3395 printf("\trlwinm %s,%s,%d,1\n",rn,rn,t+flag);
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3396 return 1;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3397 }
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
3398
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3399 int
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
3400 rexpr(int e1, int l1, int cond,int t)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3401 {
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
3402 char *s=0;
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3403 switch(car(e1)+BNOT*(!cond)) {
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3404 case GT: s=code_gt(1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3405 case UGT: s=code_ugt(1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3406 case GE: s=code_ge(1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3407 case UGE: s=code_uge(1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3408 case LT: s=code_ge(!1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3409 case ULT: s=code_uge(!1);break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3410 case LE: s=code_gt(!1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3411 case ULE: s=code_ugt(!1);break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3412 case EQ: s=code_eq(1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3413 case NEQ: s=code_eq(!1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3414 case GT+BNOT: s=code_gt(0); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3415 case UGT+BNOT: s=code_ugt(0); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3416 case GE+BNOT: s=code_ge(0); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3417 case UGE+BNOT: s=code_uge(0); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3418 case LT+BNOT: s=code_ge(!0); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3419 case ULT+BNOT: s=code_uge(!0);break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3420 case LE+BNOT: s=code_gt(!0); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3421 case ULE+BNOT: s=code_ugt(!0);break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3422 case EQ+BNOT: s=code_eq(0); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
3423 case NEQ+BNOT: s=code_eq(!0); break;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
3424 default: error(-1);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
3425 }
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
3426 g_expr(list3((t==INT?CMP:UCMP),cadr(e1),caddr(e1)));
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3427 printf("\tb%s %s,%s%d\n",s,crname(cmpflag),lpfx,l1);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3428 return l1;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3429 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3430
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
3431 static void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3432 jcond(int l, char cond)
917947ffeb7c power pc version
kono
parents:
diff changeset
3433 {
297
0f79c95df73a switch index no compile error
kono
parents: 292
diff changeset
3434 if (cond==LT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3435 printf("\tb%s %s,%s%d\n",code_ge(0),crname(cmpflag),lpfx,l);
297
0f79c95df73a switch index no compile error
kono
parents: 292
diff changeset
3436 } else if (cond==1||cond==0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3437 printf("\tb%s %s,%s%d\n",cond?"ne":"eq",crname(cmpflag),lpfx,l);
297
0f79c95df73a switch index no compile error
kono
parents: 292
diff changeset
3438 } else error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3439 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3440
917947ffeb7c power pc version
kono
parents:
diff changeset
3441 void
917947ffeb7c power pc version
kono
parents:
diff changeset
3442 jmp(int l)
917947ffeb7c power pc version
kono
parents:
diff changeset
3443 {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3444 printf("\tb\t%s%d\n",lpfx,l);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3445 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3446
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3447 extern void
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 453
diff changeset
3448 code_comment(char *s)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3449 {
307
fda28752d301 stdarg (varargs done... PowerPC, IA32 checked)
kono
parents: 305
diff changeset
3450 printf("## %s",s);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3451 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3452
917947ffeb7c power pc version
kono
parents:
diff changeset
3453 void
917947ffeb7c power pc version
kono
parents:
diff changeset
3454 code_enter(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
3455 {
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3456 #ifdef __APPLE__
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3457 if (output_mode!=TEXT_EMIT_MODE)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3458 text_mode(0);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3459 else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3460 printf("\t.align 2\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3461 if (stmode!=STATIC)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3462 printf(".globl _%s\n",name);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
3463 #ifdef DOT_SIZE
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3464 printf("\t.type\t%s,@function\n",name);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
3465 #endif
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3466 printf("_%s:\n",name);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3467 code_disp_label=fwdlabel();
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
3468 #if 0
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3469 printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label);
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
3470 #else
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
3471 printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label);
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
3472 printf("\taddis r1,r1,ha16(L_%d)\n",code_disp_label);
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
3473 #endif
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
3474 printf("\tbcl 20,31,L_%d\n",code_base = fwdlabel());
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
3475 fwddef(code_base);
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
3476 printf("\tmflr r31\n");
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
3477 max_func_args = 0;
489
79fef53141b4 fix clear_ptr_cache in MIPS/ARM.
kono
parents: 487
diff changeset
3478 clear_ptr_cache();
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3479 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3480 if (output_mode!=TEXT_EMIT_MODE)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3481 text_mode(0);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3482 else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3483 printf("\t.align 2\n");
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3484 if (stmode!=STATIC)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3485 printf(".globl %s\n",name);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3486 #ifdef DOT_SIZE
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3487 printf("\t.type\t%s,@function\n",name);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3488 #endif
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3489 printf("%s:\n",name);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3490 code_disp_label=fwdlabel();
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3491 #if 0
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3492 printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3493 #else
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3494 printf("\tla 1,%s%d@l(31)\n",lpfx,code_disp_label);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3495 printf("\taddis 1,1,%s%d@ha\n",lpfx,code_disp_label);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3496 #endif
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3497 max_func_args = 0;
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3498 clear_ptr_cache();
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3499 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3500 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3501
917947ffeb7c power pc version
kono
parents:
diff changeset
3502
917947ffeb7c power pc version
kono
parents:
diff changeset
3503 void
917947ffeb7c power pc version
kono
parents:
diff changeset
3504 code_enter1(int args)
917947ffeb7c power pc version
kono
parents:
diff changeset
3505 {
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
3506 // set_lreg(LREG_LREGISTER,0);
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
3507 set_ireg(CREG_REGISTER,0);
106
3618c0efe9d3 fix save_input_register
kono
parents: 105
diff changeset
3508 set_freg(FREG_FREGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3509 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3510
917947ffeb7c power pc version
kono
parents:
diff changeset
3511 void
917947ffeb7c power pc version
kono
parents:
diff changeset
3512 code_leave(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
3513 {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3514 int r1_offsetv;
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
3515 disp&= -SIZE_OF_INT;
603
2baddc88097d *** empty log message ***
kono
parents: 599
diff changeset
3516 r1_offsetv = -disp+max_func_args*SIZE_OF_INT -code_disp_offset0 +8+32+48;
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3517 #ifdef __APPLE__
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3518 printf(".set L_%d,%d\n",code_disp_label,-r1_offsetv);
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
3519 if (max_func_arg_label) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3520 printf(".set L_%d,%d\n",max_func_arg_label,max_func_args*SIZE_OF_INT+24);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3521 max_func_arg_label = 0;
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
3522 }
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3523 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3524 printf(".set .LC%d,%d\n",code_disp_label,-r1_offsetv);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3525 if (max_func_arg_label) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3526 printf(".set .LC%d,%d\n",max_func_arg_label,max_func_args*SIZE_OF_INT+24);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3527 max_func_arg_label = 0;
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3528 }
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3529 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3530 local_table();
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
3531 // free_all_register();
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3532 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3533
917947ffeb7c power pc version
kono
parents:
diff changeset
3534 void
917947ffeb7c power pc version
kono
parents:
diff changeset
3535 enter(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
3536 {
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3537 #ifdef __APPLE__
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3538 if (output_mode!=TEXT_EMIT_MODE)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3539 text_mode(0);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3540 else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3541 printf("\t.align 2\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3542 if (stmode!=STATIC)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3543 printf(".globl %s%s\n",npfx,name);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3544 /*
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3545 printf("\t.type\t%s,@function\n",name);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3546 */
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3547 printf("%s%s:\n",npfx,name);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3548 code_setup=fwdlabel();
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3549 printf("\tmflr r0\n");
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
3550 printf("\tbl L_%d\n",code_setup);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3551 code_base=fwdlabel();
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
3552 fwddef(code_base);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
3553 r1_offset_label = fwdlabel();
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
3554 lvar_offset_label = fwdlabel();
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3555 #if 0
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3556 printf("\taddi r30,r1,lo16(-L_%d)\n",lvar_offset_label);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
3557 printf("\tstwu r1,lo16(-L_%d)(r1)\n",r1_offset_label);
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3558 // printf("\tmr r30,r1\n");
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3559 #else
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3560 printf("\taddi r30,r1,lo16(-L_%d)\n",lvar_offset_label);
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3561 printf("\tlis r31,ha16(-L_%d)\n",r1_offset_label);
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3562 printf("\taddi r31,r31,lo16(-L_%d)\n",r1_offset_label);
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3563 printf("\tstwux r1,r1,r31\n");
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
3564 #endif
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3565 printf("\tmflr r31\n");
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3566 #else
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3567 if (output_mode!=TEXT_EMIT_MODE)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3568 text_mode(0);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3569 else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3570 printf("\t.align 2\n");
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3571 if (stmode!=STATIC)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3572 printf(".globl %s%s\n",npfx,name);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3573 /*
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3574 printf("\t.type\t%s,@function\n",name);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3575 */
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3576 printf("%s:\n",name);
805
362b0258b4db fix func_disp_offset in PS3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 804
diff changeset
3577 control = 1;
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3578 code_setup=fwdlabel();
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3579 arg_offset_label = fwdlabel();
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3580 printf("\tmflr 0\n");
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3581 printf("\tstwu %d,-%s%d@l(%d)\n",1,lpfx,arg_offset_label,1);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3582 printf("\tbl .LC%d\n",code_setup);
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3583 r1_offset_label = fwdlabel();
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3584 lvar_offset_label = fwdlabel();
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
3585
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3586 printf("\tmr %d,1\n",REG_fp);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3587 printf("\taddi %d,1,-%s%d@l\n",REG_fp,lpfx,lvar_offset_label);
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
3588 printf("\tlis %d,-%s%d@ha\n",30,lpfx,r1_offset_label);
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3589 printf("\taddi %d,%d,-%s%d@l\n",30,30,lpfx,r1_offset_label);
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
3590 printf("\tstwux 1,1,%d\n",30);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3591 #endif
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
3592 max_func_args = 0;
489
79fef53141b4 fix clear_ptr_cache in MIPS/ARM.
kono
parents: 487
diff changeset
3593 clear_ptr_cache();
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3594 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3595
917947ffeb7c power pc version
kono
parents:
diff changeset
3596 void
917947ffeb7c power pc version
kono
parents:
diff changeset
3597 enter1()
917947ffeb7c power pc version
kono
parents:
diff changeset
3598 {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3599 text_mode(0);
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
3600 // set_lreg(LREG_LREGISTER,0);
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
3601 set_ireg(CREG_REGISTER,0);
106
3618c0efe9d3 fix save_input_register
kono
parents: 105
diff changeset
3602 set_freg(FREG_FREGISTER,0);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3603 }
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3604
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3605 int
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3606 reg_save_offset()
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3607 {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3608 return -(
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3609 (REAL_MAX_REGISTER-(REG_VAR_BASE-max_reg_var))*SIZE_OF_INT+
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3610 (REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*SIZE_OF_DOUBLE
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3611 );
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3612 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3613
917947ffeb7c power pc version
kono
parents:
diff changeset
3614 void
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3615 code_label_call(int l)
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3616 {
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3617 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3618 printf("\tbl\tL_%d\n",l);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3619 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3620 printf("\tbl\t.LC%d\n",l);
660
3e1dba5758d8 *** empty log message ***
kono
parents: 655
diff changeset
3621 #endif
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3622 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3623
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3624 void
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3625 code_ret()
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3626 {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3627 printf("\tblr\n");
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3628 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3629
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3630 #ifndef __APPLE__
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3631 static int saveFP_used=0;
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3632 static char *saveFP_lib[] = {
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3633 ".saveFP: stfd 14,-144(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3634 " stfd 15,-136(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3635 " stfd 16,-128(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3636 " stfd 17,-120(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3637 " stfd 18,-112(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3638 " stfd 19,-104(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3639 " stfd 20,-96(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3640 " stfd 21,-88(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3641 " stfd 22,-80(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3642 " stfd 23,-72(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3643 " stfd 24,-64(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3644 " stfd 25,-56(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3645 " stfd 26,-48(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3646 " stfd 27,-40(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3647 " stfd 28,-32(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3648 " stfd 29,-24(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3649 " stfd 31,-16(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3650 " stfd 30,-8(1)",
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
3651 " stw 0,4(1)",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3652 " blr",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3653 ".restFP: ",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3654 " lfd 14,-144(1)",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3655 " lfd 15,-136(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3656 " lfd 16,-128(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3657 " lfd 17,-120(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3658 " lfd 18,-112(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3659 " lfd 19,-104(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3660 " lfd 20,-96(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3661 " lfd 21,-88(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3662 " lfd 22,-80(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3663 " lfd 23,-72(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3664 " lfd 24,-64(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3665 " lfd 25,-56(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3666 " lfd 26,-48(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3667 " lfd 27,-40(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3668 " lfd 28,-32(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3669 " lfd 29,-24(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3670 " lwz 0,4(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3671 " lfd 31,-16(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3672 " lwz 1,0(1)",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3673 " mtlr 0",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3674 " blr",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3675 0
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3676 };
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3677 #endif
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3678
726
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3679 static void
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3680 make_return_continuation()
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3681 {
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3682 #if R1SAVE
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3683 retcont1 = fwdlabel();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3684 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3685 fwddef(retcont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3686 if (cadr(fnptr->ty)==FLOAT||cadr(fnptr->ty)==DOUBLE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3687 printf("\tfmr %s,%s\n",fregister_name(1),fregister_name(31));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3688 printf("\tmr %s,%s\n",register_name(30),register_name(28));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3689 } else if (cadr(fnptr->ty)>0&&(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3690 car(cadr(fnptr->ty))==STRUCT ||
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3691 car(cadr(fnptr->ty))==UNION)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3692 int sz = size(cadr(fnptr->ty));
726
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3693 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3694 printf("\tli r7,%d\n",sz);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3695 printf("\tsubl r6,r7,r30\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3696 printf("\tlwz r3,lo16(%d)(r30)\n",(my_func_args-1)*SIZE_OF_INT);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3697 // emit_copy(6,3,sz,0,1,1);
726
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3698 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3699 printf("\tli 7,%d\n",sz);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3700 printf("\tsubl 6,7,%d\n",REG_fp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3701 printf("\tlwz 3,%d@l(%d)\n",(my_func_args-1)*SIZE_OF_INT,REG_fp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3702 // emit_copy(6,3,sz,0,1,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3703 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3704 printf("\tmr %s,%s\n",register_name(30),register_name(28));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3705 } else if (cadr(fnptr->ty)!=VOID) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3706 printf("\tmr %s,%s\n",register_name(3),register_name(29));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3707 printf("\tmr %s,%s\n",register_name(30),register_name(28));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3708 }
726
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3709 #if R1SAVE
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3710 jmp(retcont1);
726
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3711 #else
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3712 #endif
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3713 }
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3714
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
3715 void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3716 leave(int control, char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
3717 {
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
3718 #if R1SAVE
726
f3fccac64cbe fix ppc goto with env
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
3719 int retcont1=0;
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
3720 #else
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
3721 #endif
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3722
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3723 if (max_freg_var>=0 && max_freg_var<=3) max_freg_var=3;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3724 reg_save = reg_save_offset();
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
3725
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3726 if (control) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3727 code_set_return_register(1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3728 }
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
3729 if (retcont) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3730 if (control) jmp(retlabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3731 make_return_continuation();
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
3732 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3733 fwddef(retlabel);
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
3734 #if R1SAVE
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3735 printf("\tlwz %s,0(%s)\n",register_name(1),register_name(1));
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3736 if (retcont) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3737 fwddef(retcont1);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
3738 }
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
3739 #else
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3740 #ifdef __APPLE__
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
3741 printf("\taddi r1,r30,lo16(L_%d)\n",lvar_offset_label);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3742 #else
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3743 printf("\taddi 1,%d,%s%d@l\n",REG_fp,lpfx,lvar_offset_label);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3744 #endif
577
7e0076617c76 env switch continue..
kono
parents: 572
diff changeset
3745 #endif
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
3746 if (max_freg_var>=0) {
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3747 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3748 printf("\tlmw r%d,%d(%s)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3749 REG_VAR_BASE-max_reg_var,reg_save,register_name(1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3750 freg_save = 72-(REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*4;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3751 printf("\tb restFP+%d ; restore f%d-f31\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3752 freg_save,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3753 FREG_VAR_BASE-max_freg_var);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3754 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3755 printf("\tlmw %d,%d(%s)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3756 REG_VAR_BASE-max_reg_var,reg_save,register_name(1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3757 freg_save = 72-(REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*4;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3758 printf("\tb .restFP+%d # restore f%d-f31\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3759 freg_save,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3760 FREG_VAR_BASE-max_freg_var);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3761 #endif
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3762 } else {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3763 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3764 printf("\tlwz r0,8(r1)\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3765 printf("\tmtlr r0\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3766 printf("\tlmw r%d,%d(r1)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3767 REG_VAR_BASE-max_reg_var,reg_save);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3768 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3769 printf("\tlmw %d,%d(1)\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3770 REG_VAR_BASE-max_reg_var,reg_save);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3771 printf("\tlwz %s,4(1)\n",register_name(0));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3772 printf("\tlwz 1,0(1)\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3773 printf("\tmtlr %s\n",register_name(0));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3774 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3775 code_ret();
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3776 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3777
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
3778 disp &= -SIZE_OF_INT;
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3779 fwddef(code_setup);
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3780 #ifdef __APPLE__
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3781 printf("\tstmw %s,%d(%s)\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3782 register_name(REG_VAR_BASE-max_reg_var),reg_save,register_name(1));
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3783 printf("\tstw %s,8(%s)\n",register_name(0),register_name(1));
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3784 #else
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3785 printf("\tstmw %s,%d(%s)\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3786 register_name(REG_VAR_BASE-max_reg_var),reg_save,register_name(1));
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3787 printf("\tstw %s,4(%s)\n",register_name(0),register_name(1));
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
3788 #endif
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3789 if (max_freg_var>=0) {
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 663
diff changeset
3790 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3791 printf("\tb saveFP+%d ; save f%d-f31\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3792 freg_save,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3793 FREG_VAR_BASE-max_freg_var);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3794 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3795 saveFP_used = 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3796 printf("\tb .saveFP+%d # save f%d-f31\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3797 freg_save,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3798 FREG_VAR_BASE-max_freg_var);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3799 #endif
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
3800 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3801 printf("\tblr\n");
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
3802 }
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
3803
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
3804 code_offset_set();
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3805 local_table();
917947ffeb7c power pc version
kono
parents:
diff changeset
3806 labelno++;
208
70b1da1864f6 *** empty log message ***
kono
parents: 207
diff changeset
3807 // free_all_register();
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3808 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3809
917947ffeb7c power pc version
kono
parents:
diff changeset
3810
705
0554b7f985ee parse mode done.
kono
parents: 693
diff changeset
3811 int
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
3812 code_set_return_register(int mode) {
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
3813 if (cadr(fnptr->ty)==DOUBLE||cadr(fnptr->ty)==FLOAT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3814 set_freg(RET_FREGISTER,mode);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3815 return freg;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3816 } else if (cadr(fnptr->ty)==LONGLONG||cadr(fnptr->ty)==ULONGLONG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3817 set_lreg(RET_LREGISTER,mode);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3818 return lreg;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
3819 } else if (cadr(fnptr->ty)==VOID) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3820 return 0;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3821 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3822 set_ireg(RET_REGISTER,mode);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3823 return ireg;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3824 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3825 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3826
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
3827 int
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
3828 code_get_fixed_creg(int reg,int type) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
3829 return creg;
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
3830 }
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
3831
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3832 void
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
3833 code_set_fixed_creg(int reg,int mode,int type) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3834 if (type==FLOAT||type==DOUBLE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3835 set_freg(reg,mode);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3836 } else if (type==LONGLONG||type==ULONGLONG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3837 set_lreg(reg,mode);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3838 // use_reg(reg);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3839 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3840 set_ireg(reg,mode);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3841 }
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
3842 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
3843
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
3844 void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3845 gen_gdecl(char *n, int gpc)
917947ffeb7c power pc version
kono
parents:
diff changeset
3846 {
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
3847 /*
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3848 if (stmode!=STATIC)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3849 printf(".globl _%s\n",n);
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
3850 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3851 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3852
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3853 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3854 ascii(char *s)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3855 {
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
3856 cstring_mode();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3857 #ifdef __APPLE__
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3858 printf("\t.ascii \"");
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3859 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3860 printf("\t.string \"");
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3861 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3862 while(*s) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3863 if (*s=='\n')
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3864 printf("%cn",92);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3865 else if (*s<' ')
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3866 printf("%c%03o",92,*s);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3867 else if (*s=='\\')
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3868 printf("\\\\");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3869 else if (*s==34)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3870 printf("%c%c",92,34);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3871 else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3872 printf("%c",*s);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3873 s++;
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3874 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3875 printf("\\0%c\n\t.align 2\n",34);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3876 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3877
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3878 extern int
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3879 emit_string_label() {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3880 int lb;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3881
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3882 lb=fwdlabel();
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3883 cstring_mode();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3884 printf("%s%d:\n",lpfx,lb);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3885 return lb;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3886 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3887
518
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3888 extern void
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3889 emit_string(char *s,int t)
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3890 {
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3891 t = type_value(t);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3892 if (car(t)==ARRAY &&
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3893 (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) {
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3894 ascii(s);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3895 } else {
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3896 int l = emit_string_label();
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3897 ascii(s);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3898 emit_label(l);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3899 }
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3900 return;
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3901 }
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
3902
415
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3903 void
716
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
3904 code_align(int t)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3905 {
415
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3906 int d;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3907 switch(t) {
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3908 case CHAR: case UCHAR: return;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3909 case SHORT: case USHORT: d = data_alignment & 1; break;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3910 default: d = data_alignment & 3;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3911 }
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3912 if (d) {
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3913 printf("\t.align 2\n");
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
3914 data_alignment = 0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3915 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3916 }
917947ffeb7c power pc version
kono
parents:
diff changeset
3917
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3918 void
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
3919 emit_global(NMTBL *n,int a,int e)
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3920 {
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
3921 int t = type_value(n->ty);
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
3922 if (e>0 && car(e)==STRING && t>0 && car(t)==ARRAY &&
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3923 (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3924 cstring_mode();
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
3925 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3926 data_mode(n->nm);
542
492f06738550 working... (struct init fix)
kono
parents: 536
diff changeset
3927 if (n && n->sc!=STATIC)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
3928 printf("\t.globl\t%s%s\n",npfx,n->nm);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
3929 printf("%s%s:\n",npfx,n->nm);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3930 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3931
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3932 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3933 emit_space(int sp)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3934 {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3935 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3936 printf("\t.space\t%d\n",sp);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3937 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3938
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3939 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3940 emit_char(int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3941 {
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3942 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3943 printf("\t.byte %d\n",d);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3944 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3945
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3946 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3947 emit_short(int d)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3948 {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3949 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3950 printf("\t.short %d\n",d);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3951 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3952
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3953 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3954 emit_int(int d)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3955 {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3956 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3957 printf("\t.long %d\n",d);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3958 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3959
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3960 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3961 emit_longlong(int e)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3962 {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3963 #if LONGLONG_CODE
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
3964 long long d = lcadr(e);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3965 data_mode(0);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3966 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3967 printf("\t.long\t0x%x,0x%x\n",code_l1(d),code_l2(d));
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3968 #else
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3969 printf("\t.long\t0x%x,0x%x\n",code_l2(d),code_l1(d));
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3970 #endif
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3971 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3972 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3973
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3974 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3975 emit_double(int e)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3976 {
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3977 #if FLOAT_CODE
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
3978 double d = dcadr(e);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3979 data_mode(0);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3980 #if ENDIAN_D==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3981 printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3982 #else
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3983 printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
339
375d21a2b845 emit_data
kono
parents: 338
diff changeset
3984 #endif
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3985 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3986 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3987
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3988 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3989 emit_float(int e)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3990 {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3991 #if FLOAT_CODE
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
3992 float f = dcadr(e);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3993 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3994 printf("\t.long\t0x%x\n",*(int *)&f);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3995 #endif
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3996 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3997
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
3998 extern void
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3999 emit_address(char *s,int offset)
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4000 {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4001 data_mode(0);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
4002 if (offset)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4003 printf("\t.long %s%s+%d\n",npfx,s,offset);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
4004 else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4005 printf("\t.long %s%s\n",npfx,s);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4006 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4007
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4008 extern void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4009 emit_label(int labelno)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4010 {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4011 data_mode(0);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4012 printf("\t.long %s%d\n",lpfx,labelno);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4013 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4014
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
4015 extern void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4016 emit_data_closing(NMTBL *n)
917947ffeb7c power pc version
kono
parents:
diff changeset
4017 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
4018 #ifdef DOT_SIZE
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4019 int lb;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
4020 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4021 if (mode==GDECL) {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4022 #ifdef DOT_SIZE
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4023 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4024 data_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4025 lb=fwdlabel();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4026 printf("%s%d:\n",lpfx,lb);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4027 printf("\t.size\t%s,%s%d-%%ss\n",n->nm,lb,lpfx,npfx,n->nm);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4028 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4029 data_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4030 lb=fwdlabel();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4031 printf(".LC%d:\n",lb);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4032 printf("\t.size\t%s,%s%d-%s%s\n",n->nm,lb,lpfx,npfx,n->nm);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4033 #endif
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
4034 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4035 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4036 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4037
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4038 #ifdef __APPLE__
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4039 void
917947ffeb7c power pc version
kono
parents:
diff changeset
4040 global_table(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
4041 {
917947ffeb7c power pc version
kono
parents:
diff changeset
4042 NMTBL *n;
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
4043 int init; char *extrn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4044 init=0;
803
a5f9e5a4db1b global alignment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
4045 global_list = reversen(global_list);
a5f9e5a4db1b global alignment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
4046 text_mode(0);
350
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
4047 for(n = global_list;n!=&null_nptr;n = n->next) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4048 if ((n->sc == GVAR) && n->dsp != -1) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4049 /* n->dsp = -1 means initialized global */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4050 if (init==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4051 // data_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4052 text_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4053 printf("\t.align 3\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4054 init=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4055 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4056 int align;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4057 if ((align=attr_value(n,ALIGNED))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4058 int a = ilog(caddr(align));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4059 printf(".comm %s%s,%d,%d\n",npfx,n->nm,size(n->ty),a);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4060 } else if (size(n->ty)>1) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4061 printf(".comm %s%s,%d,2\n",npfx,n->nm,size(n->ty));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4062 } else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4063 printf(".comm %s%s,%d\n",npfx,n->nm,size(n->ty));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4064 } else if ((n->sc==STATIC) && n->dsp != -1) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4065 /* n->dsp = -1 means initialized global */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4066 if (is_code(n)||is_function(n)) continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4067 if (init==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4068 text_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4069 printf("\t.align 8\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4070 // data_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4071 init=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4072 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4073 printf(".lcomm %s%s,%d\n",npfx,n->nm,size(n->ty));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4074 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4075 }
350
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
4076 for(n = global_list;n!=&null_nptr;n = n->next) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4077 if (is_code(n)||is_function(n)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4078 extrn = n->nm;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4079 if (n->sc==EXTRN1) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4080 data_mode(0);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
4081 printf(".picsymbol_stub\n");
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4082 printf("L_%s$stub:\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4083 printf("\t.indirect_symbol _%s\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4084 printf("\tmflr r0\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4085 printf("\tbcl 20,31,L0$_%s\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4086 printf("L0$_%s:\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4087 printf("\tmflr r11\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4088 printf("\taddis r11,r11,ha16(L_%s$lazy_ptr-L0$_%s)\n",extrn,extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4089 printf("\tmtlr r0\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4090 printf("\tlwz r12,lo16(L_%s$lazy_ptr-L0$_%s)(r11)\n",extrn,extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4091 printf("\tmtctr r12\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4092 printf("\taddi r11,r11,lo16(L_%s$lazy_ptr-L0$_%s)\n",extrn,extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4093 printf("\tbctr\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4094 printf(".data\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4095 printf(".lazy_symbol_pointer\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4096 printf("L_%s$lazy_ptr:\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4097 printf("\t.indirect_symbol _%s\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4098 printf("\t.long dyld_stub_binding_helper\n");
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4099 } else if (n->sc==STATIC) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4100 text_mode(0);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
4101 printf("\t.set L_%s$stub,_%s\n",extrn,extrn);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4102 data_mode(0);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4103 printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",extrn,extrn);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4104 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4105 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4106 }
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
4107 init=0;
350
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
4108 for(n = global_list;n!=&null_nptr;n = n->next) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4109 if (n->sc == GVAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4110 if (init==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4111 printf(".data\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4112 init=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4113 }
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
4114 printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",n->nm,n->nm);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4115 }
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
4116 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4117 init = 0;
350
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
4118 for(n = global_list;n!=&null_nptr;n = n->next) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4119 if ((is_code(n)||is_function(n))&&
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4120 !has_attr(n,FNAME)) // not used as value
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4121 continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4122 if (n->sc==EXTRN1) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4123 if(init==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4124 printf(".data\n");
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4125 printf(".non_lazy_symbol_pointer\n");
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4126 init=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4127 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4128 printf("L_%s$non_lazy_ptr:\n",n->nm);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4129 printf("\t.indirect_symbol _%s\n",n->nm);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4130 printf("\t.long\t0\n");
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4131 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4132 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4133 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4134 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4135
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4136 static void
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4137 comm(NMTBL *n)
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4138 {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4139 int align = 1;
803
a5f9e5a4db1b global alignment
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
4140 if ((align=attr_value(n,ALIGNED))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4141 align = ilog(caddr(align));
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
4142 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4143 if (size(n->ty)>4)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4144 align = 2;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4145 else if (size(n->ty)>4)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4146 align = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4147 switch(n->ty) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4148 case DOUBLE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4149 case LONGLONG:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4150 case ULONGLONG:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4151 align = 8; break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4152 case INT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4153 case UNSIGNED:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4154 case FLOAT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4155 align = 4; break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4156 case SHORT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4157 case USHORT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4158 align = 2; break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4159 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4160 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4161 printf("\t.comm %s,%d,%d\n",n->nm,size(n->ty),align);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4162 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4163
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4164 void
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4165 global_table(void)
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4166 {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4167 NMTBL *n;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4168 int init;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4169 init=0;
809
476b53b61630 PS3 PPU stdarg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 805
diff changeset
4170 global_list = reversen(global_list);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4171 for(n=global_list;n;n=n->next) {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4172 if ((n->sc == GVAR) && n->dsp != -1) {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4173 /* n->dsp = -1 means initialized global */
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4174 if (init==0) {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4175 data_mode(0);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4176 init=1;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4177 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4178 comm(n);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4179 } else if ((n->sc==STATIC) && n->dsp != -1) {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4180 /* n->dsp = -1 means initialized global */
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4181 if (is_code(n)||is_function(n)) continue;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4182 if (init==0) {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4183 data_mode(0);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4184 init=1;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4185 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4186 // printf(".local %s\n",n->nm);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4187 comm(n);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4188 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4189 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4190 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4191 #endif
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4192
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4193 #ifdef __APPLE__
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4194 void
917947ffeb7c power pc version
kono
parents:
diff changeset
4195 local_table(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
4196 {
917947ffeb7c power pc version
kono
parents:
diff changeset
4197 NMTBL *n;
917947ffeb7c power pc version
kono
parents:
diff changeset
4198 int init;
917947ffeb7c power pc version
kono
parents:
diff changeset
4199 init=0;
917947ffeb7c power pc version
kono
parents:
diff changeset
4200 /* static local variables */
350
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
4201 for(n = local_static_list;n!=&null_nptr;n = n->next) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4202 if (n->sc == STATIC) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4203 if (init==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4204 data_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4205 init=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4206 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4207 if (n->dsp != -1) /* initialized static */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4208 printf(".lcomm _%s,%d\n",n->nm,size(n->ty));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4209 printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",n->nm,n->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4210 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4211 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4212 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4213 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4214 void
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4215 local_table(void)
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4216 {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4217 NMTBL *n;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4218 int init;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4219 init=0;
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4220 /* static local variables */
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4221 for(n = local_static_list;n!=&null_nptr;n = n->next) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4222 if (n->sc == STATIC) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4223 if (init==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4224 data_mode(0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4225 init=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4226 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4227 if (n->dsp != -1) /* initialized static */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4228 printf(".lcomm %s,%d\n",n->nm,size(n->ty));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4229 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4230 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4231 }
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4232 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4233
917947ffeb7c power pc version
kono
parents:
diff changeset
4234 void
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4235 cstring_mode(int align)
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4236 {
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4237 if (output_mode!=RODATA_EMIT_MODE) {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4238 #ifdef __APPLE__
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4239 printf(".cstring\n\t.align 2\n");
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4240 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4241 printf("\t.section\t.rodata\n\t.align 2\n");
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4242 #endif
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4243 output_mode = RODATA_EMIT_MODE;
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4244 }
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4245 }
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4246
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4247 void
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4248 text_mode(int align)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4249 {
917947ffeb7c power pc version
kono
parents:
diff changeset
4250 if (output_mode!=TEXT_EMIT_MODE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4251 printf(".text\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4252 printf("\t.align 2\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4253 output_mode = TEXT_EMIT_MODE;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4254 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4255 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4256
917947ffeb7c power pc version
kono
parents:
diff changeset
4257 void
917947ffeb7c power pc version
kono
parents:
diff changeset
4258 data_mode(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
4259 {
917947ffeb7c power pc version
kono
parents:
diff changeset
4260 if (output_mode!=DATA_EMIT_MODE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4261 printf(".data\n");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4262 output_mode = DATA_EMIT_MODE;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4263 }
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4264 /*
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4265 if (name)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4266 printf("\t.type\t%s,@object\n",name);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4267 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4268 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4269
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
4270 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
4271
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4272 /* floating point */
917947ffeb7c power pc version
kono
parents:
diff changeset
4273
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4274 static int float_one_lib_used=0;
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4275 static char *float_one_lib[] = {
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4276 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4277 /* ".literal8", */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4278 " .align 3",
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4279 "__float_one:",
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4280 " .long 1065353216",
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4281 ".text",
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
4282 /* ".set L__float_one$non_lazy_ptr,__float_one", */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4283 0
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
4284 };
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4285 static int float_zero_lib_used=0;
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4286 static char *float_zero_lib[] = {
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4287 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4288 /* ".literal8", */
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4289 " .align 3",
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4290 "__float_zero:",
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4291 " .long 0",
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4292 ".text",
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
4293 /* ".set L__float_zero$non_lazy_ptr,__float_zero", */
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4294 0
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4295 };
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4296
739
0c7a6ae119ba i64 continue... compiler compiled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 726
diff changeset
4297 char * fstore(int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4298 {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
4299 return (d?"stfd":"stfs");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4300 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4301
917947ffeb7c power pc version
kono
parents:
diff changeset
4302 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
4303 fload(int d)
917947ffeb7c power pc version
kono
parents:
diff changeset
4304 {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
4305 return d?"lfd":"lfs";
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4306 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4307
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4308 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
4309 code_cmp_dregister(int e2,int d,int label,int cond)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4310 {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
4311 char *frn,*rrn,*grn;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
4312 int greg,r;
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4313 grn = fregister_name(greg = get_dregister(d));
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4314 use_float(d,e2);
132
07eb1249f07a *** empty log message ***
kono
parents: 131
diff changeset
4315 frn = register_name(e2);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
4316 float_zero_lib_used=1;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
4317 r = get_ptr_cache(&float_zero);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
4318 rrn = register_name(r);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4319 printf("\tlfs %s,0(%s)\n",grn,rrn);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
4320 inc_cmpflag();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4321 printf("\tfcmpu %s,%s,%s\n",crname(cmpflag),grn,frn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4322 free_register(greg);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
4323 jcond(label,cond);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
4324 return;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4325 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4326
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4327 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4328 code_dregister(int e2,int freg,int d)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4329 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4330 use_float(d,freg);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4331 if (freg!=e2) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4332 if (is_int_reg(e2)) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4333 printf("\tfmr %s,%s\n",fregister_name(freg),fregister_name(e2));
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4334 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4335 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4336
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4337 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4338 code_dassign_gvar(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4339 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4340 use_float(d,freg);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
4341 code_ldf(fstore(d),fregister_name(freg),cadr(e2),
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4342 get_ptr_cache(ncaddr(e2)));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4343 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4344
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4345 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4346 code_dassign_lvar(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4347 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4348 use_float(d,freg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4349 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4350 printf("\t%s %s,",fstore(d),fregister_name(freg));
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4351 lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4352 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4353
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4354 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4355 code_dassign(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4356 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4357 use_float(d,freg);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4358 printf("\t%s %s,0(%s)\n",fstore(d),fregister_name(freg),register_name(e2));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4359 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4360
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4361 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4362 code_dassign_dregister(int e2,int d,int freg) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4363 use_float(d,freg);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4364 if (e2!=freg) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4365 printf("\tfmr %s,%s\n",fregister_name(e2),fregister_name(freg));
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4366 }
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4367 }
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4368
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4369 static double d0 = 1.0;
917947ffeb7c power pc version
kono
parents:
diff changeset
4370
917947ffeb7c power pc version
kono
parents:
diff changeset
4371 int
917947ffeb7c power pc version
kono
parents:
diff changeset
4372 code_d1(double d)
917947ffeb7c power pc version
kono
parents:
diff changeset
4373 {
917947ffeb7c power pc version
kono
parents:
diff changeset
4374 int *i = (int *)&d0; int *j = (int *)&d;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
4375 return (i[1] == 0x3ff00000)?j[0]:j[1];
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4376 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4377
917947ffeb7c power pc version
kono
parents:
diff changeset
4378 int
917947ffeb7c power pc version
kono
parents:
diff changeset
4379 code_d2(double d)
917947ffeb7c power pc version
kono
parents:
diff changeset
4380 {
917947ffeb7c power pc version
kono
parents:
diff changeset
4381 int *i = (int *)&d0; int *j = (int *)&d;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
4382 return (i[1] == 0x3ff00000)?j[1]:j[0];
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4383 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4384
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4385 int
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4386 code_f(double d)
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4387 {
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4388 float f = d;
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4389 int *j = (int *)&f;
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4390 return *j;
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4391 }
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4392
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4393 static void emit_dconst0(ValuePtr value, int lb, void *arg)
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4394 {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4395 long d = (long) arg;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4396 printf(" \t.data\n\t.align 3\n");
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4397 printf("%s%d:\n",lpfx,lb);
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4398 if (d) {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4399 #if ENDIAN_D==0
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4400 printf("\t.long\t0x%x,0x%x\n",code_d1(value->d),code_d2(value->d));
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4401 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4402 printf("\t.long\t0x%x,0x%x\n",code_d2(value->d),code_d1(value->d));
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4403 #endif
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4404 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4405 printf("\t.long\t0x%x\n",code_f(value->f));
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4406 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4407 if (output_mode==TEXT_EMIT_MODE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4408 printf(".text\n");
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4409 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4410 text_mode(0);
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4411 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4412 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4413
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4414 /* load double / float const
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4415 we should keep what constant we have create
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4416 */
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4417
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4418 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4419 code_dconst(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4420 {
780
c5315f472912 ia32/powerpc regression test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 779
diff changeset
4421 int sz;
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4422 Value value;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4423 value.d = dcadr(e2);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
4424 int r;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4425 char *rrn,*frn;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4426 use_float(d,freg);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4427 frn = fregister_name(freg);
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4428 if (value.d==0.0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4429 float_zero_lib_used=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4430 r = get_ptr_cache(&float_zero);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4431 rrn = register_name(r);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4432 printf("\tlfs %s,0(%s)\n",frn,rrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4433 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4434 }
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4435 if (value.d==1.0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4436 float_one_lib_used=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4437 r = get_ptr_cache(&float_one);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4438 rrn = register_name(r);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4439 printf("\tlfs %s,0(%s)\n",frn,rrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4440 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4441 }
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4442 if (d) {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4443 sz = sizeof(double);
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4444 } else {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4445 sz = sizeof(float);
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4446 value.f = (float) value.d;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4447 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4448
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4449 long d_mode = d;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4450 int lb = get_data_label(&value,sz,emit_dconst0, (void*) d_mode);
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
4451
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4452 rrn = register_name((r=get_register()));
780
c5315f472912 ia32/powerpc regression test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 779
diff changeset
4453 // use_reg(r); // to clear ptr cache
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4454 code_label_value(lb,r);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4455 if (d) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4456 printf("\tlfd %s,0(%s)\n",frn,rrn);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4457 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4458 printf("\tlfs %s,0(%s)\n",frn,rrn);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4459 }
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
4460 free_register(r);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4461 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4462
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4463 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4464 code_builtin_fabsf(int e)
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4465 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4466 char *frn;
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4467 g_expr0(e);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4468 use_float(0,freg);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4469 frn = fregister_name(freg);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4470 printf("\tfabs %s,%s\n",frn,frn);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4471 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4472
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4473 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4474 code_builtin_fabs(int e)
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4475 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4476 char *frn;
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4477 g_expr0(e);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4478 use_float(1,freg);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4479 frn = fregister_name(freg);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4480 printf("\tfabs %s,%s\n",frn,frn);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4481 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4482
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4483 static void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4484 code_inf(int d)
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4485 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4486 int lb;
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4487 int r;
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4488 char *rrn,*frn;
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4489 int freg = USE_CREG;
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4490
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4491 use_float(d,freg);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4492 frn = fregister_name(freg);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4493 rrn = register_name((r=get_register()));
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4494 use_reg(r); // to clear ptr cache
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4495 printf(" \t.data\n\t.align 3\n");
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4496 lb=fwdlabel();
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4497 printf("L_%d:\n",lb);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4498 if (d) {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4499 #if ENDIAN_D==0
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4500 printf("\t.long\t0x%x,0x%x\n",0,0x7ff00000);
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4501 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4502 printf("\t.long\t0x%x,0x%x\n",0x7ff00000,0);
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4503 #endif
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4504 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4505 printf("\t.long\t0x%x\n",0x7f800000);
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4506 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4507 if (output_mode==TEXT_EMIT_MODE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4508 printf(".text\n");
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4509 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4510 text_mode(0);
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4511 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4512 code_label_value(lb,r);
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4513 if (d) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4514 printf("\tlfd %s,0(%s)\n",frn,rrn);
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4515 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4516 printf("\tlfs %s,0(%s)\n",frn,rrn);
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4517 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4518 free_register(r);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4519 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4520
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4521 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4522 code_builtin_inff()
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4523 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4524 code_inf(0);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4525 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4526
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4527 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4528 code_builtin_inf()
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4529 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4530 code_inf(1);
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4531 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4532
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
4533
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4534
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4535 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4536 code_dneg(int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4537 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4538 char *frn;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4539 use_float(d,freg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4540 frn = fregister_name(freg);
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4541 printf("\tfneg %s,%s\n",frn,frn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4542 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4543
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4544 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4545 code_d2i()
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4546 {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4547 char *frn;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4548 char *crn;
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
4549 int e2 = new_lvar(SIZE_OF_DOUBLE);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4550
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4551 use_double0();
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4552 frn = fregister_name(freg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4553 use_int0();
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4554 crn = register_name(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4555
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4556 free_lvar(e2);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
4557 printf("\tfctiwz %s,%s\n",frn,frn);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4558 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4559 printf("\tstfd %s,",frn); lvar(e2);
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
4560 lvar_intro(e2+SIZE_OF_DOUBLE-SIZE_OF_INT);
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
4561 printf("\tlwz %s,",crn); lvar(e2+SIZE_OF_DOUBLE-SIZE_OF_INT);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4562 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4563
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4564 static int i2d_lib_used=0;
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4565 #ifdef __APPLE__
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4566 static char *i2d_lib[] = {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4567 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4568 /* ".literal8", */
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4569 " .align 3",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4570 "__i2dLC0:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4571 " .long 1127219200",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4572 " .long -2147483648",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4573 ".text",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4574 " .align 2",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4575 "i2d_:",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4576 " mflr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4577 " bcl 20,31,__i2dL1$pb",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4578 "__i2dL1$pb:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4579 " mflr r10",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4580 " mtlr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4581 " xoris r3,r3,0x8000",
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4582 " stw r3,-28(r1)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4583 " lis r0,0x4330",
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4584 " stw r0,-32(r1)",
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4585 " lfd f0,-32(r1)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4586 " addis r9,r10,ha16(__i2dLC0-__i2dL1$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4587 " lfd f1,lo16(__i2dLC0-__i2dL1$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4588 " fsub f1,f0,f1",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4589 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4590 0
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4591 };
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4592 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4593 static char *i2d_lib[] = {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4594 ".data",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4595 /* ".literal8", */
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4596 " .align 3",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4597 "__i2dLC0:",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4598 " .long 1127219200",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4599 " .long -2147483648",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4600 ".text",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4601 " .align 2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4602 "i2d_:",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4603 " xoris 3,3,0x8000",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4604 " stw 3,-28(1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4605 " lis 0,0x4330",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4606 " stw 0,-32(1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4607 " lfd 0,-32(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4608 " lis 9,__i2dLC0@ha",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4609 " lfd 1,__i2dLC0@l(9)",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4610 " fsub 1,0,1",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4611 " blr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4612 0
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4613 };
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4614 #endif
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4615
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4616 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4617 code_i2d()
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4618 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
4619 i2d_lib_used = 1;
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
4620 clear_ptr_cache();
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
4621 code_save_stacks();
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
4622 set_ireg(RET_REGISTER,1);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4623 printf("\tbl i2d_\n");
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
4624 set_freg(RET_FREGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4625 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4626
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4627 static int d2u_lib_used=0;
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4628 #ifdef __APPLE__
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4629 static char *d2u_lib[] = {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4630 /* ".literal8", */
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4631 " .align 3",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4632 "__d2uLC0:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4633 " .long 1105199104",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4634 " .long 0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4635 ".text",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4636 " .align 2",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4637 "d2u_:",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4638 " mflr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4639 " bcl 20,31,__d2uL1$pb",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4640 "__d2uL1$pb:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4641 " mflr r10",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4642 " mtlr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4643 " addis r9,r10,ha16(__d2uLC0-__d2uL1$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4644 " lfd f0,lo16(__d2uLC0-__d2uL1$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4645 " fcmpu cr0,f1,f0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4646 " cror 2,1,2",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4647 " beq- cr0,__d2uL2",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4648 " fctiwz f0,f1",
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4649 " stfd f0,-32(r1)",
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4650 " lwz r3,-28(r1)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4651 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4652 "__d2uL2:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4653 " addis r9,r10,ha16(__d2uLC0-__d2uL1$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4654 " lfd f0,lo16(__d2uLC0-__d2uL1$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4655 " fsub f0,f1,f0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4656 " fctiwz f0,f0",
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4657 " stfd f0,-24(r1)",
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4658 " lwz r3,-20(r1)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4659 " xoris r3,r3,0x8000",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4660 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4661 0
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4662 };
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4663 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4664 static char *d2u_lib[] = {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4665 /* ".literal8", */
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4666 " .align 3",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4667 "__d2uLC0:",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4668 " .long 1105199104",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4669 " .long 0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4670 ".text",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4671 " .align 2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4672 "d2u_:",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4673 " lis 9,__d2uLC0@ha",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4674 " lfd 0,__d2uLC0@l(9)",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4675 " fcmpu 0,1,0",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4676 " cror 2,1,2",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4677 " beq- 0,__d2uL2",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4678 " fctiwz 0,1",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4679 " stfd 0,-32(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4680 " lwz 3,-28(1)",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4681 " blr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4682 "__d2uL2:",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4683 " lis 9,__d2uLC0@ha",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4684 " lfd 0,__d2uLC0@l(9)",
663
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4685 " fsub 0,1,0",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4686 " fctiwz 0,0",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4687 " stfd 0,-24(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4688 " lwz 3,-20(1)",
92a401bef729 *** empty log message ***
kono
parents: 662
diff changeset
4689 " xoris 3,3,0x8000",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4690 " blr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4691 0
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4692 };
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4693 #endif
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4694
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4695 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4696 code_d2u()
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4697 {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
4698 code_save_stacks();
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
4699 clear_ptr_cache();
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4700 d2u_lib_used=1;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
4701 set_freg(RET_FREGISTER,1);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4702 printf("\tbl d2u_\n");
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
4703 set_ireg(RET_REGISTER,0);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4704 }
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
4705
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4706 static int u2d_lib_used=0;
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4707 #ifdef __APPLE__
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4708 static char *u2d_lib[] = {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4709 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4710 /* ".literal8", */
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4711 " .align 3",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4712 "__u2dLC1:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4713 " .long 1127219200",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4714 " .long 0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4715 ".text",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4716 " .align 2",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4717 "u2d_:",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4718 " mflr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4719 " bcl 20,31,__u2dL2$pb",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4720 "__u2dL2$pb:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4721 " mflr r10",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4722 " mtlr r0",
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4723 " stw r3,-28(r1)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4724 " lis r0,0x4330",
375
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4725 " stw r0,-32(r1)",
91849fdeea60 PowerPC large offset.
kono
parents: 371
diff changeset
4726 " lfd f0,-32(r1)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4727 " addis r9,r10,ha16(__u2dLC1-__u2dL2$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4728 " lfd f1,lo16(__u2dLC1-__u2dL2$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4729 " fsub f1,f0,f1",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4730 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4731 0
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4732 };
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4733 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4734 static char *u2d_lib[] = {
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4735 ".data",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4736 /* ".literal8", */
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4737 " .align 3",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4738 "__u2dLC1:",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4739 " .long 1127219200",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4740 " .long 0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4741 ".text",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4742 " .align 2",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4743 ".u2d_:",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4744 " stw 3,-28(1)",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4745 " lis 0,0x4330",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4746 " stw 0,-32(1)",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4747 " lfd 0,-32(1)",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4748 " lis 9,__u2dLC1@ha",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4749 " lfd 1,__u2dLC1@l(9)",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4750 " fsub 1,0,1",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4751 " blr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4752 0
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4753 };
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4754 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4755
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4756 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4757 code_u2d()
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4758 {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
4759 code_save_stacks();
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
4760 clear_ptr_cache();
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4761 u2d_lib_used = 1;
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
4762 set_ireg(RET_REGISTER,1);
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4763 #ifdef __APPLE__
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
4764 printf("\tbl u2d_\n");
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4765 #else
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4766 printf("\tbl .u2d_\n");
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
4767 #endif
228
21b311266011 *** empty log message ***
kono
parents: 227
diff changeset
4768 set_freg(RET_FREGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4769 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4770
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4771 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4772 code_d2f() { }
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4773 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4774 code_f2d() { }
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4775 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4776 code_f2i() { code_d2i(); }
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4777 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4778 code_f2u() { code_d2u(); }
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4779 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4780 code_i2f() { code_i2d(); }
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4781 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4782 code_u2f() { code_u2d(); }
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4783
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4784 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4785 code_drgvar(int e2,int d,int freg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4786 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4787 use_float(d,freg);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
4788 code_ldf(fload(d),fregister_name(freg),cadr(e2),
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4789 get_ptr_cache(ncaddr(e2)));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4790 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4791
917947ffeb7c power pc version
kono
parents:
diff changeset
4792
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4793 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4794 code_drlvar(int e2,int d,int freg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4795 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4796 use_float(d,freg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4797 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4798 printf("\t%s %s,",fload(d),fregister_name(freg)); lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4799 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4800
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4801 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
4802 code_cmp_drgvar(int e2,int reg,int d,int label,int cond)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4803 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4804 char *frn;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4805 int g=get_dregister(d);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4806 char *grn=fregister_name(g);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4807
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4808 use_float(d,reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4809 frn=fregister_name(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4810
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
4811 code_ldf(fload(1),grn,cadr(e2),
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4812 get_ptr_cache(ncaddr(e2)));
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
4813 inc_cmpflag();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4814 printf("\tfcmpu %s,%s,%s\n",crname(cmpflag),frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4815 free_register(g);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
4816 jcond(label,cond);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4817 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4818
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4819 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
4820 code_cmp_drlvar(int e2,int reg,int d,int label,int cond)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4821 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4822 char *frn;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4823 int g=get_dregister(d);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
4824 char *grn=fregister_name(g);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4825
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4826 use_float(d,reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4827 frn=fregister_name(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4828
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4829 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
4830 printf("\t%s %s,",fload(1),grn); lvar(e2);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
4831 inc_cmpflag();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
4832 printf("\tfcmpu %s,%s,%s\n",crname(cmpflag),frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4833 free_register(g);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
4834 jcond(label,cond);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4835 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4836
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
4837 void
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4838 dtosop(int op,int reg,int oreg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4839 {
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
4840 char *opn="";
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4841 char *frn;
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4842 char *grn;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4843 int ox = -1;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4844
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4845 use_float(1,reg);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4846 if(oreg==-1) {
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4847 error(-1);
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4848 } else if (oreg<= -REG_LVAR_OFFSET) {
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4849 ox = get_dregister(1); if (ox<0) error(-1);
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4850 use_reg(ox);
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4851 code_drlvar(oreg+REG_LVAR_OFFSET,1,ox);
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4852 oreg = ox;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4853 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4854 grn=fregister_name(oreg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4855 frn=fregister_name(reg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4856 switch(op) {
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4857 case FADD:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4858 case DADD: opn="fadd"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4859 case FSUB:
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
4860 case DSUB: opn="fsub"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4861 case FDIV:
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
4862 case DDIV: opn="fdiv"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4863 case FMUL:
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
4864 case DMUL: opn="fmul"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4865 case FCMP:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4866 case DCMP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4867 inc_cmpflag();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4868 printf("\tfcmpu %s,%s,%s\n",crname(cmpflag),frn,grn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4869 if (ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4870 return;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4871 case FCMPGE:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4872 case DCMPGE:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4873 inc_cmpflag();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4874 printf("\tfcmpu %s,%s,%s\n",crname(cmpflag),frn,grn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4875 if (ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4876 return;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
4877 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4878 error(-1); return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4879 }
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4880 printf("\t%s %s,%s,%s\n",opn,frn,frn,grn);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4881 if (ox!=-1) free_register(ox);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4882 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4883
917947ffeb7c power pc version
kono
parents:
diff changeset
4884 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4885 code_dassop(int op,int reg,int d) {
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4886 /* we have lvalue in creg, applied floating value is in freg */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4887 // (*creg) op = pop()
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4888 int xreg=emit_dpop(d);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4889 char *crn;
209
7bfc1435cdc6 regv fix done
kono
parents: 208
diff changeset
4890 char *frn;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4891
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4892 crn=register_name(ireg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4893 use_float(d,reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4894 frn =fregister_name(reg);
209
7bfc1435cdc6 regv fix done
kono
parents: 208
diff changeset
4895
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4896 printf("\t%s %s,0(%s)\n",fload(d),frn,crn);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4897 dtosop(op,reg,xreg);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
4898 printf("\t%s %s,0(%s)\n",fstore(d),frn,crn);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
4899 emit_dpop_free(xreg,d);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4900 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4901
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
4902 void
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
4903 code_register_dassop(int reg,int op,int d) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4904 // reg op= dpop()
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
4905 int xreg=emit_dpop(d);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4906 dtosop(op,reg,xreg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4907 emit_dpop_free(xreg,d);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
4908 }
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4909
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4910 static int
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4911 code_dload_1(int d)
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4912 {
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4913 int r,g;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4914 char *drn,*grn;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4915 // load 1
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4916 float_one_lib_used=1;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4917 r = get_ptr_cache(&float_one);
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4918 drn=register_name(r);
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4919 grn=fregister_name(g=get_dregister(d));
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4920 printf("\tlfs %s,0(%s)\n",grn,drn);
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4921 return g;
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4922 }
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4923
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4924 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
4925 code_dpreinc(int e1,int e2,int d,int reg) {
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4926 char *frn,*crn,*grn;
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4927 int g;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4928
144
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
4929 if (car(e2)==DREGISTER||car(e2)==FREGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4930 crn=register_name(cadr(e2));
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4931 grn = fregister_name(g = code_dload_1(d));
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4932 if (reg==USE_CREG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4933 reg=get_dregister(d); if (!reg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4934 set_freg(reg,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4935 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4936 frn=fregister_name(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4937 printf("\t%s %s,%s,%s\n",(caddr(e1)>0)?"fadd":"fsub",crn,crn,grn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4938 if (use && reg!=cadr(e2))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4939 printf("\tfmr %s,%s\n",frn,crn);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4940 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4941 g_expr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4942 if (!is_int_reg(creg)) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4943 crn=register_name(ireg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4944 if (reg==USE_CREG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4945 reg=get_dregister(d); if (!reg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4946 set_freg(reg,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4947 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4948 frn=fregister_name(reg);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4949 grn = fregister_name(g = code_dload_1(d));
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4950 printf("\t%s %s,0(%s)\n",fload(d),frn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4951 printf("\t%s %s,%s,%s\n",(caddr(e1)>0)?"fadd":"fsub",frn,frn,grn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4952 printf("\t%s %s,0(%s)\n",fstore(d),frn,crn);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4953 }
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4954 free_register(g);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4955 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4956
917947ffeb7c power pc version
kono
parents:
diff changeset
4957 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
4958 code_dpostinc(int e1,int e2,int d,int reg) {
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4959 char *frn,*crn,*grn;
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4960 int g;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
4961
144
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
4962 if (car(e2)==DREGISTER||car(e2)==FREGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4963 crn=register_name(cadr(e2));
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4964 grn = fregister_name(g = code_dload_1(d));
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4965 if (reg==USE_CREG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4966 reg=get_dregister(d); if (!reg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4967 set_freg(reg,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4968 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4969 frn=fregister_name(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4970 if (use && reg!=cadr(e2))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4971 printf("\tfmr %s,%s\n",frn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4972 printf("\t%s %s,%s,%s\n",(caddr(e1)>0)?"fadd":"fsub",crn,crn,grn);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4973 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4974 g_expr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4975 if (!is_int_reg(creg)) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4976 crn=register_name(ireg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4977 if (reg==USE_CREG) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4978 reg=get_dregister(d); if (!reg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4979 set_freg(reg,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4980 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4981 frn=fregister_name(reg);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
4982 grn = fregister_name(g = code_dload_1(d));
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4983 printf("\t%s %s,0(%s)\n",fload(d),frn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4984 printf("\t%s %s,%s,%s\n",(caddr(e1)>0)?"fadd":"fsub",grn,frn,grn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
4985 printf("\t%s %s,0(%s)\n",fstore(d),grn,crn);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
4986 }
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
4987 free_register(g);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
4988 }
917947ffeb7c power pc version
kono
parents:
diff changeset
4989
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4990 static int
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4991 drexpr_bool(int e1,int reg)
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4992 {
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
4993 int flag=-1,eq=-1,neg=-1,t;
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4994 char *rn;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4995 switch(car(e1)) {
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4996 case DOP+GT: case FOP+GT: flag = 2; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4997 case DOP+GE: case FOP+GE: flag = 2; eq=3; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4998 case DOP+LT: case FOP+LT: flag = 1; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
4999 case DOP+LE: case FOP+LE: flag = 1; eq=3; break;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5000 case DOP+EQ: case FOP+EQ: flag = 3; break;
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
5001 case DOP+NEQ: case FOP+NEQ: flag = 3; neg=3; break;
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5002 default: return 0;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5003 }
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5004 g_expr(list3(DCMP,cadr(e1),caddr(e1)));
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5005 use_int(reg);
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5006 rn = register_name(reg);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
5007 t = CRBITSIZ*cmpflag;
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5008 if (eq>0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5009 printf("\tcror %d,%d,%d\n",t+flag-1,t+eq-1,t+flag-1);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
5010 }
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
5011 if (neg>0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5012 neg = t+neg-1,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5013 printf("\tcrnor %d,%d,%d\n",neg,neg,neg);
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5014 }
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5015 printf("\tmfcr %s\n",rn);
289
55e611476cba *** empty log message ***
kono
parents: 288
diff changeset
5016 printf("\trlwinm %s,%s,%d,1\n",rn,rn,t+flag);
288
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5017 return 1;
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5018 }
ce7b4d90bc24 PowerPC code bool
kono
parents: 287
diff changeset
5019
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
5020 int
229
d793c84b3679 *** empty log message ***
kono
parents: 228
diff changeset
5021 drexpr(int e1, int e2,int l1, int op,int cond)
d793c84b3679 *** empty log message ***
kono
parents: 228
diff changeset
5022 {
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5023 if (!cond) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5024 switch(op) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5025 case FOP+GT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5026 return drexpr(e2,e1,l1,FOP+GE,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5027 case FOP+GE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5028 return drexpr(e2,e1,l1,FOP+GT,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5029 case FOP+EQ:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5030 op=FOP+NEQ; break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5031 case FOP+NEQ:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5032 op=FOP+EQ; break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5033 case DOP+GT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5034 return drexpr(e2,e1,l1,DOP+GE,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5035 case DOP+GE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5036 return drexpr(e2,e1,l1,DOP+GT,1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5037 case DOP+EQ:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5038 op=DOP+NEQ; break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5039 case DOP+NEQ:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5040 op=DOP+EQ; break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5041 }
229
d793c84b3679 *** empty log message ***
kono
parents: 228
diff changeset
5042 }
234
eccea7c904ee float powerpc drexp done (?)
kono
parents: 233
diff changeset
5043 g_expr(list3(DCMP, e1,e2));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5044 switch(op) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5045 case DOP+GT: case FOP+GT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5046 printf("\tbgt\t%s,%s%d\n",crname(cmpflag),lpfx,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5047 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5048 case DOP+GE: case FOP+GE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5049 printf("\tbge\t%s,%s%d\n",crname(cmpflag),lpfx,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5050 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5051 case DOP+EQ: case FOP+EQ:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5052 printf("\tbeq\t%s,%s%d\n",crname(cmpflag),lpfx,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5053 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5054 case DOP+NEQ: case FOP+NEQ:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5055 printf("\tbne\t%s,%s%d\n",crname(cmpflag),lpfx,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5056 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5057 }
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
5058 return l1;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5059 }
917947ffeb7c power pc version
kono
parents:
diff changeset
5060
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
5061 int emit_dpop(int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5062 {
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
5063 int xreg,reg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
5064 xreg=pop_fregister();
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
5065 if (xreg<= -REG_LVAR_OFFSET) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5066 reg = get_dregister(d);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
5067 code_drlvar(REG_LVAR_OFFSET+xreg,1,reg);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5068 free_lvar(REG_LVAR_OFFSET+xreg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5069 xreg=reg;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
5070 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
5071 return xreg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5072 }
917947ffeb7c power pc version
kono
parents:
diff changeset
5073
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5074 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5075 emit_dpop_free(int e1,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5076 {
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
5077 if (e1>=0 && e1!=creg && regs[e1]!=REG_VAR)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5078 free_register(e1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5079 }
917947ffeb7c power pc version
kono
parents:
diff changeset
5080
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5081 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5082 emit_dpush(int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5083 {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
5084 int new_reg;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5085 if (!is_float_reg(creg)) error(-1);
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
5086 if (freg_sp>MAX_MAX) error(-1);
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
5087 new_reg = get_dregister(1); /* 絶対に取れる */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
5088 freg_stack[freg_sp++] = freg; /* push するかわりにレジスタを使う */
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
5089 creg = freg = new_reg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
5090 }
917947ffeb7c power pc version
kono
parents:
diff changeset
5091
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5092 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5093
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5094 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5095
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5096
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5097 /* 64bit int part */
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5098 static void
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
5099 lmove(int to,int from) // to <= from
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5100 {
227
ed92cef127f1 *** empty log message ***
kono
parents: 226
diff changeset
5101 int tmp;
ed92cef127f1 *** empty log message ***
kono
parents: 226
diff changeset
5102 if (regv_h(to)==regv_l(from)&&(regv_l(to)==regv_h(from))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5103 tmp = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5104 printf("\tmr %s,%s\n",register_name(tmp),lregister_name_low(from));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5105 printf("\tmr %s,%s\n",lregister_name_high(to),lregister_name_high(from));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5106 printf("\tmr %s,%s\n",lregister_name_low(to),register_name(tmp));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5107 free_register(tmp);
227
ed92cef127f1 *** empty log message ***
kono
parents: 226
diff changeset
5108 } else if (regv_h(to)==regv_l(from)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5109 printf("\tmr %s,%s\n",lregister_name_low(to),lregister_name_low(from));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5110 printf("\tmr %s,%s\n",lregister_name_high(to),lregister_name_high(from));
226
a31e1d24c097 *** empty log message ***
kono
parents: 223
diff changeset
5111 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5112 printf("\tmr %s,%s\n",lregister_name_high(to),lregister_name_high(from));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5113 printf("\tmr %s,%s\n",lregister_name_low(to),lregister_name_low(from));
226
a31e1d24c097 *** empty log message ***
kono
parents: 223
diff changeset
5114 }
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5115 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5116
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5117 static void
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5118 pcond(char *s,int cmpflag,int l1)
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5119 {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5120 printf("\tb%s %s,%s%d\n",s,crname(cmpflag),lpfx,l1);
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5121 }
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5122
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5123 static int
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5124 lcmp(int op,int cond)
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5125 {
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5126 if (op==LOP+UGT||op==LOP+UGE) {
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5127 return UCMP;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5128 } else if (op==LOP+LE||op==LOP+GE) {
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5129 return CMP;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5130 } else {
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5131 return CMP;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5132 }
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5133 }
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5134
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
5135 int
229
d793c84b3679 *** empty log message ***
kono
parents: 228
diff changeset
5136 lrexpr(int e1, int e2,int l1, int op,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5137 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5138 int reg;
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5139 int e3;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5140 int l2;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5141 int op1,cr0,cr1;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5142
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5143 g_expr(e1);
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5144 emit_lpush();
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5145 g_expr(e2);
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5146 e3 = emit_lpop();
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5147 if (!is_longlong_reg(creg)) error(-1);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5148 reg = lreg;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5149 op1 = lcmp(op,cond);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5150 tosop(op1,regv_h(e3),regv_h(reg));
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5151 cr0 = cmpflag;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
5152 tosop(op1,regv_l(e3),regv_l(reg));
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5153 cr1 = cmpflag;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5154
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5155 l2 = fwdlabel();
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5156 // cond==0 jump on false condtion ( if(x) => rexpr(.. cond=0 ...) )
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5157 switch(op+(!cond)*BNOT) {
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5158 case LOP+GT:
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5159 case LOP+GE:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5160 pcond(code_gt(1),cr0,1?l1:l2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5161 pcond(code_eq(0),cr0,1?l2:l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5162 break;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5163 case LOP+UGT:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5164 case LOP+UGE:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5165 pcond(code_ugt(1),cr0,1?l1:l2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5166 pcond(code_eq(0), cr0,1?l2:l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5167 break;
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5168 case LOP+EQ:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5169 pcond(code_eq(0),cr0,(1?l2:l1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5170 pcond(code_eq(cond),cr1,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5171 break;
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5172 case LOP+NEQ:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5173 pcond(code_eq(0),cr0,(1?l1:l2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5174 pcond(code_eq(!1),cr1,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5175 break;
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5176 case LOP+GT+BNOT:
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5177 case LOP+GE+BNOT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5178 pcond(code_gt(1),cr0,0?l1:l2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5179 pcond(code_eq(0),cr0,0?l2:l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5180 break;
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5181 case LOP+UGT+BNOT:
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5182 case LOP+UGE+BNOT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5183 pcond(code_ugt(1),cr0,0?l1:l2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5184 pcond(code_eq(0), cr0,0?l2:l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5185 break;
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5186 case LOP+EQ+BNOT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5187 pcond(code_eq(0),cr0,(0?l2:l1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5188 pcond(code_eq(0),cr1,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5189 break;
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5190 case LOP+NEQ+BNOT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5191 pcond(code_eq(0),cr0,(0?l1:l2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5192 pcond(code_eq(!0),cr1,l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5193 break;
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5194 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5195 error(-1);
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5196 }
433
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5197 switch(op+BNOT*(!cond)) {
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5198 case LOP+GT: pcond(code_gt(1), cr1,l1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5199 case LOP+GE: pcond(code_ge(1), cr1,l1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5200 case LOP+UGT: pcond(code_ugt(1), cr1,l1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5201 case LOP+UGE: pcond(code_uge(1), cr1,l1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5202 case LOP+GT+BNOT: pcond(code_gt(0), cr1,l1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5203 case LOP+GE+BNOT: pcond(code_ge(0), cr1,l1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5204 case LOP+UGT+BNOT: pcond(code_ugt(0), cr1,l1); break;
b9566a04b6e2 *** empty log message ***
kono
parents: 432
diff changeset
5205 case LOP+UGE+BNOT: pcond(code_uge(0), cr1,l1); break;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5206 }
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5207 fwddef(l2);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5208 emit_lpop_free(e3);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
5209 return l1;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 273
diff changeset
5210 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5211
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5212 int
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5213 emit_lpop()
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5214 {
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5215 int xreg,reg;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 234
diff changeset
5216 xreg=lreg_stack[--lreg_sp];
210
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5217 if (xreg<= -REG_LVAR_OFFSET) {
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5218 reg = get_lregister();
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5219 code_lrlvar(REG_LVAR_OFFSET+xreg,reg);
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5220 free_lvar(REG_LVAR_OFFSET+xreg);
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5221 xreg = reg;
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5222 }
f21651f85344 *** empty log message ***
kono
parents: 209
diff changeset
5223 return xreg;
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5224 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5225
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5226 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5227 code_lregister(int e2,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5228 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5229 use_longlong(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5230 if (reg!=e2) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5231 lmove(reg,e2);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5232 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5233 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5234
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5235 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
5236 code_cmp_lregister(int reg,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5237 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5238 use_longlong(reg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5239 printf("\tor %s,%s,%s\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5240 lregister_name_low(reg),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5241 lregister_name_low(reg),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5242 lregister_name_high(reg));
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
5243 inc_cmpflag();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5244 printf("\tcmpwi %s,%s,0\n",crname(cmpflag),lregister_name_low(reg));
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
5245 jcond(label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5246 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5247
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5248 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
5249 code_cmp_lrgvar(int e1,int creg,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5250 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5251 use_longlong(creg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5252 code_lrgvar(e1,creg);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
5253 code_cmp_lregister(creg,label,cond);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5254 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5255
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5256 void
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
5257 code_cmp_lrlvar(int e1,int creg,int label,int cond)
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5258 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5259 use_longlong(creg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5260 code_lrlvar(e1,creg);
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
5261 code_cmp_lregister(creg,label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5262 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5263
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5264 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5265 code_lassign(int e2,int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5266 {
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5267 char *drn = register_name(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5268 char *crn_h;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5269 char *crn_l;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5270
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5271 use_longlong(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5272 crn_h = lregister_name_high(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5273 crn_l = lregister_name_low(creg);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5274 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5275 printf("\tstw %s,0(%s)\n",crn_l,drn);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5276 printf("\tstw %s,%d(%s)\n",crn_h,SIZE_OF_INT,drn);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5277 #else
271
e1a96bdbe527 MIPS continue...
kono
parents: 269
diff changeset
5278 printf("\tstw %s,0(%s)\n",crn_h,drn);
e1a96bdbe527 MIPS continue...
kono
parents: 269
diff changeset
5279 printf("\tstw %s,%d(%s)\n",crn_l,SIZE_OF_INT,drn);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5280 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5281 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5282
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5283 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5284 code_lassign_gvar(int e2,int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5285 {
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5286 int r;
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
5287 use_longlong(creg);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
5288 r = get_ptr_cache(ncaddr(e2));
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5289 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5290 code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5291 code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5292 #else
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
5293 code_ldf(cstore(0),lregister_name_high(creg),cadr(e2),r);
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
5294 code_ldf(cstore(0),lregister_name_low(creg),cadr(e2)+SIZE_OF_INT,r);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5295 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5296 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5297
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5298 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5299 code_lassign_lvar(int e2,int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5300 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5301 char *crn_h;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5302 char *crn_l;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5303
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5304 use_longlong(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5305 crn_h = lregister_name_high(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5306 crn_l = lregister_name_low(creg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5307 lvar_intro(e2);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5308 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5309 printf("\tstw %s,",crn_l);lvar(e2);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5310 printf("\tstw %s,",crn_h);lvar(e2+SIZE_OF_INT);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5311 #else
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5312 printf("\tstw %s,",crn_h);lvar(e2);
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
5313 printf("\tstw %s,",crn_l);lvar(e2+SIZE_OF_INT);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5314 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5315 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5316
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5317 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5318 code_lassign_lregister(int e2,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5319 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5320 use_longlong(reg);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5321 if (e2!=reg) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5322 lmove(e2,reg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5323 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5324 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5325
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
5326 static long long ll0 = 1LL;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5327
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5328 static int
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5329 code_l1(long long d)
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5330 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
5331 int *i = (int *)&ll0; int *j = (int *)&d;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5332 return (i[1] == 1)?j[1]:j[0];
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5333 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5334
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5335 static int
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5336 code_l2(long long d)
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5337 {
207
8a3516f6eb66 *** empty log message ***
kono
parents: 206
diff changeset
5338 int *i = (int *)&ll0; int *j = (int *)&d;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5339 return (i[1] == 1)?j[0]:j[1];
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5340 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
5341
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5342 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5343 code_lconst(int e1,int creg)
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5344 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5345 use_longlong(creg);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5346 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5347 code_const(code_l1(lcadr(e1)),regv_h(creg));
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5348 code_const(code_l2(lcadr(e1)),regv_l(creg));
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5349 #else
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5350 code_const(code_l1(lcadr(e1)),regv_l(creg));
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5351 code_const(code_l2(lcadr(e1)),regv_h(creg));
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5352 #endif
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5353 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5354
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5355 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5356 code_lneg(int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5357 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5358 use_longlong(creg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5359 printf("\tsubfic %s,%s,0\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5360 lregister_name_low(creg),lregister_name_low(creg));
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5361 printf("\tsubfze %s,%s\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5362 lregister_name_high(creg),lregister_name_high(creg));
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5363 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5364
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5365 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5366 code_lrgvar(int e1,int creg)
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5367 {
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5368 int r;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5369 char *crn_h;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5370 char *crn_l;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5371 use_longlong(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5372 crn_h = lregister_name_high(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5373 crn_l = lregister_name_low(creg);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
5374 r = get_ptr_cache(ncaddr(e1));
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5375 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5376 code_ldf(cload(0),crn_l,cadr(e1),r);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5377 code_ldf(cload(0),crn_h,cadr(e1)+SIZE_OF_INT,r);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5378 #else
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
5379 code_ldf(cload(0),crn_h,cadr(e1),r);
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
5380 code_ldf(cload(0),crn_l,cadr(e1)+SIZE_OF_INT,r);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5381 #endif
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5382 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5383
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5384 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5385 code_lrlvar(int e1,int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5386 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5387 char *crn_h;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5388 char *crn_l;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5389 use_longlong(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5390 crn_h = lregister_name_high(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5391 crn_l = lregister_name_low(creg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5392 lvar_intro(e1);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5393 #if ENDIAN_L==0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5394 printf("\tlwz %s,",crn_l); lvar(e1);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5395 printf("\tlwz %s,",crn_h); lvar(e1+SIZE_OF_INT);
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5396 #else
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5397 printf("\tlwz %s,",crn_h); lvar(e1);
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
5398 printf("\tlwz %s,",crn_l); lvar(e1+SIZE_OF_INT);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
5399 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5400 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5401
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5402 #if 0
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5403 static int lumod_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5404 static char *lumod_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5405 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5406
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5407 static int lmod_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5408 static char *lmod_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5409 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5410
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5411 static int ludiv_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5412 static char *ludiv_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5413 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5414
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5415 static int ldiv_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5416 static char *ldiv_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5417 };
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5418 #endif
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5419
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5420 static int lsrd_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5421 static char *lsrd_lib[] = {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5422 #ifdef __APPLE__
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5423 ".text",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5424 " .align 2",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5425 ".lsrd__:",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5426 " mr. r5,r5",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5427 " beqlr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5428 " subfic r2,r5,32",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5429 " stw r3,-32(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5430 " stw r4,-28(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5431 " cmpwi cr7,r2,0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5432 " bgt+ cr7,L__lsrd1",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5433 " neg r0,r2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5434 " lwz r2,-32(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5435 " li r9,0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5436 " srw r2,r2,r0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5437 " stw r9,-48(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5438 " b L__lsrd2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5439 "L__lsrd1: lwz r0,-32(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5440 " slw r9,r0,r2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5441 " lwz r2,-28(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5442 " srw r0,r0,r5",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5443 " srw r2,r2,r5",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5444 " stw r0,-48(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5445 " or r2,r2,r9",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5446 "L__lsrd2: stw r2,-44(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5447 " lwz r3,-48(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5448 " lwz r4,-44(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5449 " blr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5450 #else
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5451 ".text",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5452 " .align 2",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5453 ".lsrd__:",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5454 " mr. 5,5",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5455 " beqlr",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5456 " subfic 8,5,32",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5457 " stw 3,-32(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5458 " stw 4,-28(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5459 " cmpwi 7,8,0",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5460 " bgt+ 7,.L__lsrd1",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5461 " neg 0,2",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5462 " lwz 8,-32(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5463 " li 9,0",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5464 " srw 8,8,0",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5465 " stw 9,-48(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5466 " b .L__lsrd2",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5467 ".L__lsrd1: lwz 0,-32(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5468 " slw 9,0,8",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5469 " lwz 8,-28(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5470 " srw 0,0,5",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5471 " srw 8,8,5",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5472 " stw 0,-48(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5473 " or 8,8,9",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5474 ".L__lsrd2: stw 8,-44(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5475 " lwz 3,-48(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5476 " lwz 4,-44(1)",
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5477 " blr",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5478 #endif
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5479 0
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5480 };
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5481
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5482 static int asld_lib_used=0;
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5483 static char *asld_lib[] = {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5484 #ifdef __APPLE__
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5485 ".text",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5486 " .align 2",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5487 ".asld__:",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5488 " mr. r5,r5",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5489 " beqlr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5490 " subfic r2,r5,32",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5491 " stw r3,-32(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5492 " stw r4,-28(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5493 " cmpwi cr7,r2,0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5494 " bgt+ cr7,L__asld1",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5495 " neg r0,r2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5496 " lwz r2,-28(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5497 " li r9,0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5498 " slw r2,r2,r0",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5499 " stw r9,-44(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5500 " b L__asld2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5501 "L__asld1: lwz r0,-28(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5502 " srw r9,r0,r2",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5503 " lwz r2,-32(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5504 " slw r0,r0,r5",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5505 " slw r2,r2,r5",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5506 " stw r0,-44(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5507 " or r2,r2,r9",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5508 "L__asld2: stw r2,-48(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5509 " lwz r3,-48(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5510 " lwz r4,-44(r1)",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5511 " blr",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5512 #else
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5513 ".text",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5514 " .align 2",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5515 ".asld__:",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5516 " mr. 5,5",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5517 " beqlr",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5518 " subfic 8,5,32",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5519 " stw 3,-32(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5520 " stw 4,-28(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5521 " cmpwi 7,8,0",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5522 " bgt+ 7,.L__asld1",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5523 " neg 0,8",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5524 " lwz 8,-28(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5525 " li 9,0",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5526 " slw 8,8,0",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5527 " stw 9,-44(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5528 " b .L__asld2",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5529 ".L__asld1: lwz 0,-28(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5530 " srw 9,0,8",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5531 " lwz 8,-32(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5532 " slw 0,0,5",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5533 " slw 8,8,5",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5534 " stw 0,-44(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5535 " or 8,8,9",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5536 ".L__asld2: stw 8,-48(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5537 " lwz 3,-48(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5538 " lwz 4,-44(1)",
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5539 " blr",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5540 #endif
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5541 0
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5542 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5543
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5544 static int asrd_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5545 static char *asrd_lib[] = {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5546 #ifdef __APPLE__
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5547 ".text",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5548 " .align 2",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5549 ".asrd__:",
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5550 " mr. r5,r5",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5551 " beqlr",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5552 " subfic r2,r5,32",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5553 " stw r3,-32(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5554 " stw r4,-28(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5555 " cmpwi cr7,r2,0",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5556 " bgt+ cr7,L__asrd1",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5557 " lwz r0,-32(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5558 " neg r2,r2",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5559 " sraw r2,r0,r2",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5560 " srawi r0,r0,31",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5561 " b L__asrd2",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5562 "L__asrd1: lwz r0,-32(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5563 " slw r9,r0,r2",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5564 " lwz r2,-28(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5565 " sraw r0,r0,r5",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5566 " srw r2,r2,r5",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5567 " or r2,r2,r9",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5568 "L__asrd2: stw r0,-48(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5569 " stw r2,-44(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5570 " lwz r3,-48(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5571 " lwz r4,-44(r1)",
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5572 " blr",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5573 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5574 ".text",
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5575 " .align 2",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5576 ".asrd__:",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5577 " mr. 5,5",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5578 " beqlr",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5579 " subfic 8,5,32",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5580 " stw 3,-32(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5581 " stw 4,-28(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5582 " cmpwi 7,8,0",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5583 " bgt+ 7,.L__asrd1",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5584 " lwz 0,-32(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5585 " neg 8,8",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5586 " sraw 8,0,8",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5587 " srawi 0,0,31",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5588 " b .L__asrd2",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5589 ".L__asrd1: lwz 0,-32(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5590 " slw 9,0,8",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5591 " lwz 8,-28(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5592 " sraw 0,0,5",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5593 " srw 8,8,5",
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5594 " or 8,8,9",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5595 ".L__asrd2: stw 0,-48(1)",
673
442e90958386 PS3 PPc almot done...
kono
parents: 672
diff changeset
5596 " stw 8,-44(1)",
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5597 " lwz 3,-48(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5598 " lwz 4,-44(1)",
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5599 " blr",
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5600 #endif
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5601 0
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5602 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5603
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5604 #endif
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5605
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5606 static void
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5607 extern_conv(char *conv)
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5608 {
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5609 code_save_stacks();
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5610 clear_ptr_cache();
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5611 extern_define(conv,0,FUNCTION,1);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5612 #ifdef __APPLE__
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5613 printf("\tbl L_%s$stub\n",conv);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5614 #else
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5615 printf("\tbl %s\n",conv);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5616 #endif
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5617 }
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5618
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5619 #if FLOAT_CODE
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
5620 #if 0
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5621 static int d2ll_lib_used=0;
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5622 static char *d2ll_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5623 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5624
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5625 static int d2ull_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5626 static char *d2ull_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5627 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5628
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5629 static int f2ll_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5630 static char *f2ll_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5631 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5632
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5633 static int f2ull_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5634 static char *f2ull_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5635 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5636
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5637 static int ll2d_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5638 static char *ll2d_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5639 };
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5640
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5641 static int ll2f_lib_used=0;
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5642 static char *ll2f_lib[] = {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5643 };
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
5644 #endif
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5645
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5646 #endif
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5647
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5648 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5649 code_asld_lib(int reg,int oreg)
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5650 {
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5651 code_save_stacks();
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5652 clear_ptr_cache();
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5653 asld_lib_used = 1;
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5654 set_lreg_operand(reg,1);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5655 set_lreg(RET_LREGISTER,0);
228
21b311266011 *** empty log message ***
kono
parents: 227
diff changeset
5656 if (regv_l(oreg)!=5) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5657 printf("\tmr %s,%s\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5658 register_name(5),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5659 lregister_name_low(oreg));
228
21b311266011 *** empty log message ***
kono
parents: 227
diff changeset
5660 }
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5661 printf("\tbl .asld__\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5662 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5663
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5664 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5665 code_asrd_lib(int reg,int oreg) // ___ashrdi3$stub
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5666 {
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5667 code_save_stacks();
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5668 clear_ptr_cache();
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5669 asrd_lib_used = 1;
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5670 set_lreg_operand(reg,1);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5671 set_lreg(RET_LREGISTER,0);
228
21b311266011 *** empty log message ***
kono
parents: 227
diff changeset
5672 if (regv_l(oreg)!=5) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5673 printf("\tmr %s,%s\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5674 register_name(5),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5675 lregister_name_low(oreg));
228
21b311266011 *** empty log message ***
kono
parents: 227
diff changeset
5676 }
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5677 printf("\tbl .asrd__\n");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5678 }
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5679
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5680 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5681 code_lsrd_lib(int reg,int oreg) // ___lshrdi3$stub
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5682 {
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5683 code_save_stacks();
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5684 clear_ptr_cache();
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5685 lsrd_lib_used = 1;
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5686 set_lreg_operand(reg,1);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5687 set_lreg(RET_LREGISTER,0);
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5688 if (regv_l(oreg)!=5) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5689 printf("\tmr %s,%s\n",
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5690 register_name(5),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5691 lregister_name_low(oreg));
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5692 }
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
5693 printf("\tbl .lsrd__\n");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5694 }
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5695
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5696 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5697 code_ldiv_lib(int reg,int oreg) // ___divdi3$stub
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5698 {
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5699 code_save_stacks();
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5700 clear_ptr_cache();
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5701 set_lreg_operand(reg,1);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5702 set_lreg(RET_LREGISTER,0);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5703 set_lreg_operand1(oreg,1);
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5704 extern_conv("__divdi3");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5705 }
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5706
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5707 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5708 code_ludiv_lib(int reg,int oreg) // ___udivdi3$stub
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5709 {
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5710 code_save_stacks();
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5711 clear_ptr_cache();
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5712 set_lreg_operand(reg,1);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5713 set_lreg(RET_LREGISTER,0);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5714 set_lreg_operand1(oreg,1);
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5715 extern_conv("__udivdi3");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5716 }
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5717
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5718 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5719 code_lmod_lib(int reg,int oreg) // ___moddi3$stub
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5720 {
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5721 code_save_stacks();
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5722 clear_ptr_cache();
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5723 set_lreg_operand(reg,1);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5724 set_lreg(RET_LREGISTER,0);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5725 set_lreg_operand1(oreg,1);
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5726 extern_conv("__moddi3");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5727 }
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5728
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5729 static void
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5730 code_lumod_lib(int reg,int oreg) // ___umoddi3$stub
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5731 {
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5732 code_save_stacks();
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
5733 clear_ptr_cache();
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5734 set_lreg(RET_LREGISTER,0);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5735 set_lreg_operand(reg,1);
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 252
diff changeset
5736 set_lreg_operand1(oreg,1);
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
5737 extern_conv("__umoddi3");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5738 }
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5739
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
5740 #define check_lreg(reg) if (reg!=lreg) { lmove(reg,lreg); /* reg<=lreg */ }
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
5741
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
5742 // reg = reg op oreg
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5743
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5744 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5745 ltosop(int op,int reg,int oreg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5746 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5747 int dx = -1;
252
1452eb0eab20 *** empty log message ***
kono
parents: 246
diff changeset
5748 int ox = -1;
531
19f5882997f5 *** empty log message ***
kono
parents: 530
diff changeset
5749 int creg_mode = (reg==USE_CREG);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5750 char *orn_h,*crn_h,*drn_h;
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5751 char *orn_l,*crn_l,*drn_l;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5752 // creg = creg op oreg
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5753
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5754 use_longlong(reg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5755 if(oreg==-1) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5756 error(-1);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5757 } else if (oreg<= -REG_LVAR_OFFSET) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5758 ox = get_lregister(); if (ox<0) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5759 use_reg(ox);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
5760 code_lrlvar(oreg+REG_LVAR_OFFSET,ox);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5761 oreg = ox;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5762 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5763
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5764 switch(op) {
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5765 case LLSHIFT:
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5766 case LULSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5767 code_asld_lib(reg,oreg); // ___ashldi3$stub
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5768 check_lreg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5769 if(ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5770 return;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5771 case LRSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5772 code_asrd_lib(reg,oreg); // ___ashrdi3$stub
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5773 check_lreg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5774 if(ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5775 return;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5776 case LURSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5777 code_lsrd_lib(reg,oreg); // ___lshrdi3$stub
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5778 check_lreg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5779 if(ox!=-1) free_register(ox);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5780 return;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5781 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5782 orn_h = lregister_name_high(oreg);
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5783 orn_l = lregister_name_low(oreg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5784 crn_h = lregister_name_high(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5785 crn_l = lregister_name_low(reg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5786 switch(op) {
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5787 case LADD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5788 printf("\taddc %s,%s,%s\n",crn_l,crn_l,orn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5789 printf("\tadde %s,%s,%s\n",crn_h,crn_h,orn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5790 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5791 case LSUB:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5792 printf("\tsubfc %s,%s,%s\n",crn_l,orn_l,crn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5793 printf("\tsubfe %s,%s,%s\n",crn_h,orn_h,crn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5794 break;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5795 case LCMP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5796 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5797 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5798 case LBAND:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5799 printf("\tand %s,%s,%s\n",crn_l,crn_l,orn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5800 printf("\tand %s,%s,%s\n",crn_h,crn_h,orn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5801 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5802 case LEOR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5803 printf("\txor %s,%s,%s\n",crn_l,crn_l,orn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5804 printf("\txor %s,%s,%s\n",crn_h,crn_h,orn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5805 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5806 case LBOR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5807 printf("\tor %s,%s,%s\n",crn_l,crn_l,orn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5808 printf("\tor %s,%s,%s\n",crn_h,crn_h,orn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5809 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5810 case LMUL:
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5811 case LUMUL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5812 // code_save_stacks();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5813 // clear_ptr_cache();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5814 dx=get_lregister(); if (dx<0) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5815 use_reg(dx);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5816 drn_l = lregister_name_low(dx);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5817 drn_h = lregister_name_high(dx);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5818 /*
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5819 drn_l = l32( crn_l * orn_l);
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5820 drn_h = h32( crn_l * orn_l);
593
c139d4d9307c ltosop optimize
kono
parents: 590
diff changeset
5821 crn_h = l32( crn_h * orn_l);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5822 drn_h = drn_h + crn_h;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5823 crn_l = l32( crn_l * orn_h);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5824 crn_h = drn_h + crn_l;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5825 crn_l = drn_l;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5826 */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5827 printf("\tmulhwu %s,%s,%s\n",drn_h,crn_l,orn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5828 printf("\tmullw %s,%s,%s\n", drn_l,crn_l,orn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5829 printf("\tmullw %s,%s,%s\n", crn_h,crn_h,orn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5830 printf("\tadd %s,%s,%s\n", drn_h,drn_h,crn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5831 printf("\tmullw %s,%s,%s\n", crn_l,orn_h,crn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5832 printf("\tadd %s,%s,%s\n", crn_h,drn_h,crn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5833 printf("\tmr %s,%s\n", crn_l,drn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5834 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5835 case LDIV:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5836 code_ldiv_lib(reg,oreg); // ___divdi3$stub
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5837 if (!creg_mode) check_lreg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5838 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5839 case LUDIV:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5840 code_ludiv_lib(reg,oreg); // ___udivdi3$stub
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5841 if (!creg_mode) check_lreg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5842 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5843 case LMOD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5844 code_lmod_lib(reg,oreg); // ___moddi3$stub
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5845 if (!creg_mode) check_lreg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5846 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5847 case LUMOD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5848 code_lumod_lib(reg,oreg); // ___umoddi3$stub
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5849 if (!creg_mode) check_lreg(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5850 break;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5851 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5852 error(-1);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5853 }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
5854 if(ox!=-1) free_register(ox);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5855 if(dx!=-1) free_register(dx);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5856 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5857
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5858 int
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5859 code_lconst_op_p(int op,int e)
214
4f459364c334 *** empty log message ***
kono
parents: 213
diff changeset
5860 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
5861 int v;
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
5862 if (car(e)==LCONST) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5863 if (!(-32766<lcadr(e)&&lcadr(e)<32767)) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5864 v = lcadr(e);
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
5865 } else if (car(e)==CONST) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5866 if (!(-32766<cadr(e)&&cadr(e)<32767)) return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5867 v = cadr(e);
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
5868 } else return 0;
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
5869
214
4f459364c334 *** empty log message ***
kono
parents: 213
diff changeset
5870 switch(op) {
436
kono
parents: 435
diff changeset
5871 case LMUL: case LUMUL: case LUDIV:
kono
parents: 435
diff changeset
5872 // case LDIV:
kono
parents: 435
diff changeset
5873 return ilog(v);
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5874 case LLSHIFT:
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5875 case LULSHIFT:
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5876 case LRSHIFT:
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5877 case LURSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5878 return (0<=v&&v<=64);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5879 case LADD:
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5880 case LSUB:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5881 return 1;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5882 case LBOR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5883 return (v>0);
214
4f459364c334 *** empty log message ***
kono
parents: 213
diff changeset
5884 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5885 return 0;
214
4f459364c334 *** empty log message ***
kono
parents: 213
diff changeset
5886 }
4f459364c334 *** empty log message ***
kono
parents: 213
diff changeset
5887 }
4f459364c334 *** empty log message ***
kono
parents: 213
diff changeset
5888
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
5889 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5890 loprtc(int op,int creg,int e)
213
kono
parents: 212
diff changeset
5891 {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5892 char *crn_h;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5893 char *crn_l;
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
5894 char *grn;
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
5895 int v=0;
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
5896 int greg;
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
5897
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5898 use_longlong(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5899 crn_h = lregister_name_high(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5900 crn_l = lregister_name_low(creg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
5901
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
5902 if (car(e)==LCONST) v = lcadr(e);
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
5903 else if (car(e)==CONST) v = cadr(e);
213
kono
parents: 212
diff changeset
5904
kono
parents: 212
diff changeset
5905 switch(op) {
436
kono
parents: 435
diff changeset
5906 case LMUL: case LUMUL:
kono
parents: 435
diff changeset
5907 v=ilog(v);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5908 case LLSHIFT:
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5909 case LULSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5910 if (v==0) return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5911 if (v==32) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5912 code_register(regv_l(creg),regv_h(creg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5913 code_const(0,regv_l(creg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5914 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5915 } else if (v>31) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5916 printf("\tslwi %s,%s,%d\n",crn_h,crn_l,v-32);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5917 code_const(0,regv_l(creg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5918 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5919 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5920 greg = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5921 grn = register_name(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5922 use_reg(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5923 printf("\tsrwi %s,%s,%d\n",grn,crn_l,32-v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5924 printf("\tslwi %s,%s,%d\n",crn_h,crn_h,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5925 printf("\tor %s,%s,%s\n",crn_h,grn,crn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5926 printf("\tslwi %s,%s,%d\n",crn_l,crn_l,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5927 free_register(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5928 return;
436
kono
parents: 435
diff changeset
5929 case LDIV:
kono
parents: 435
diff changeset
5930 v=ilog(v);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5931 case LRSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5932 if (v==0) return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5933 if (v==32) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5934 code_register(regv_h(creg),regv_l(creg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5935 printf("\tsrawi %s,%s,31\n",crn_h,crn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5936 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5937 } else if (v>31) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5938 printf("\tsrawi %s,%s,%d\n",crn_l,crn_h,v-32);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5939 printf("\tsrawi %s,%s,31\n",crn_h,crn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5940 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5941 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5942 greg = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5943 use_reg(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5944 grn = register_name(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5945 printf("\tsrwi %s,%s,%d\n",grn,crn_l,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5946 printf("\tinsrwi %s,%s,%d,0\n",grn,crn_h,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5947 printf("\tsrawi %s,%s,%d\n",crn_h,crn_h,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5948 printf("\tmr %s,%s\n",crn_l,grn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5949 free_register(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5950 return;
436
kono
parents: 435
diff changeset
5951 case LUDIV:
kono
parents: 435
diff changeset
5952 v=ilog(v);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5953 case LURSHIFT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5954 if (v==0) return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5955 if (v==32) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5956 code_register(regv_h(creg),regv_l(creg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5957 code_const(0,regv_h(creg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5958 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5959 } else if (v>31) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5960 printf("\tsrwi %s,%s,%d\n",crn_l,crn_h,v-32);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5961 code_const(0,regv_h(creg));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5962 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5963 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5964 greg = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5965 use_reg(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5966 grn = register_name(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5967 printf("\tslwi %s,%s,%d\n",grn,crn_h,32-v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5968 printf("\tsrwi %s,%s,%d\n",crn_l,crn_l,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5969 printf("\tor %s,%s,%s\n",crn_l,grn,crn_l);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5970 printf("\tsrwi %s,%s,%d\n",crn_h,crn_h,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5971 free_register(greg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5972 return;
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
5973 case LSUB:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5974 v = -v;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5975 case LADD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5976 printf("\taddic %s,%s,%d\n",crn_l,crn_l,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5977 if (v<0)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5978 printf("\taddme %s,%s\n",crn_h,crn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5979 else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5980 printf("\taddze %s,%s\n",crn_h,crn_h);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5981 break;
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
5982 case LBOR:
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5983 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5984 printf("\tori %s,%s,lo16(%d)\n",crn_l,crn_l,v);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
5985 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5986 printf("\tori %s,%s,%d@l\n",crn_l,crn_l,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5987 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5988 break;
213
kono
parents: 212
diff changeset
5989 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
5990 error(-1);
213
kono
parents: 212
diff changeset
5991 }
kono
parents: 212
diff changeset
5992 }
kono
parents: 212
diff changeset
5993
kono
parents: 212
diff changeset
5994
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5995 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5996 emit_lpop_free(int xreg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
5997 {
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 587
diff changeset
5998 if (xreg>=0 && xreg!=creg && regs[xreg]!=REG_VAR)
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
5999 free_register(xreg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6000 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6001
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6002 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6003 emit_lpush()
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6004 {
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6005 int new_reg;
212
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6006 if (!is_longlong_reg(creg)) error(-1);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6007 if (lreg_sp>MAX_MAX) error(-1);
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
6008 new_reg = get_lregister(); /* 絶対に取れる(?) */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
6009 lreg_stack[lreg_sp++] = creg; /* push するかわりにレジスタを使う */
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6010 lreg = creg = new_reg;
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6011 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6012
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6013 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6014 code_i2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6015 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6016 char *crn,*crn_h,*crn_l;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6017 int reg0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6018 crn = register_name(reg0 = ireg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6019 use_longlong(reg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6020 crn_h = lregister_name_high(lreg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6021 crn_l = lregister_name_low(lreg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6022 if (reg0!=regv_l(lreg))
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6023 printf("\tmr %s,%s\n",crn_l,crn);
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6024 printf("\tsrawi %s,%s,31\n",crn_h,crn_l);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6025 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6026
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6027 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6028 code_i2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6029 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6030 code_i2ll(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6031 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6032
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6033 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6034 code_u2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6035 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6036 char *crn,*crn_h,*crn_l;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6037 int reg0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6038 crn = register_name(reg0 = ireg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6039 use_longlong(reg);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6040 crn_h = lregister_name_high(lreg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6041 crn_l = lregister_name_low(lreg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6042 if (reg0!=regv_l(lreg))
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6043 printf("\tmr %s,%s\n",crn_l,crn);
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6044 printf("\tli %s,0\n",crn_h);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6045 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6046
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6047 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6048 code_u2ull(int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6049 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6050 code_u2ll(creg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6051 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6052
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6053 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6054 code_ll2i(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6055 {
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
6056 char *crn_l;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6057 int reg0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6058 crn_l = lregister_name_low(reg0=lreg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6059 use_int(reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6060 if (ireg!=regv_l(reg0))
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6061 printf("\tmr %s,%s\n",register_name(ireg),crn_l);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6062 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6063
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6064 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6065 code_ll2u(int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6066 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6067 code_ll2i(creg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6068 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6069
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6070 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6071 code_ull2i(int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6072 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6073 code_ll2i(creg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6074 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6075
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6076 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6077 code_ull2u(int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6078 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6079 code_ll2i(creg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6080 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6081
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6082 #if FLOAT_CODE
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6083
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6084 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6085 code_d2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6086 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6087 // fixdfdi$stub
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6088 set_freg(RET_FREGISTER,1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6089 extern_conv("__fixdfdi");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6090 set_lreg(RET_LREGISTER,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6091 if (reg!=USE_CREG&&reg!=RET_LREGISTER)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6092 use_longlong(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6093 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6094
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6095 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6096 code_d2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6097 {
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6098 set_freg(RET_FREGISTER,1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6099 extern_conv("__fixunsdfdi");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6100 set_lreg(RET_LREGISTER,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6101 if (reg!=USE_CREG&&reg!=RET_LREGISTER)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6102 use_longlong(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6103 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6104
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6105 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6106 code_f2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6107 {
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6108 set_freg(RET_FREGISTER,1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6109 extern_conv("__fixdfdi");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6110 set_lreg(RET_LREGISTER,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6111 if (reg!=USE_CREG&&reg!=RET_LREGISTER)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6112 use_longlong(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6113 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6114
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6115 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6116 code_f2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6117 {
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6118 set_freg(RET_FREGISTER,1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6119 extern_conv("__fixsfdi");
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6120 set_lreg(RET_LREGISTER,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6121 if (reg!=USE_CREG&&reg!=RET_LREGISTER)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6122 use_longlong(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6123 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6124
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6125 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6126 code_ll2d(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6127 {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6128 set_lreg(RET_LREGISTER,1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6129 extern_conv("__floatdidf");
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6130 set_freg(RET_FREGISTER,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6131 if (reg!=USE_CREG&&reg!=RET_FREGISTER)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6132 use_float(1,reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6133 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6134
217
a4d3818f5353 *** empty log message ***
kono
parents: 216
diff changeset
6135
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6136 void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6137 code_ll2f(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6138 {
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6139 set_lreg(RET_LREGISTER,1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6140 extern_conv("__floatdisf");
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6141 set_freg(RET_FREGISTER,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
6142 if (reg!=USE_CREG&&reg!=RET_FREGISTER)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6143 use_float(0,reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6144 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6145
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6146 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6147 code_ull2d(int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6148 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6149 code_ll2d(creg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6150 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6151
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6152 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6153 code_ull2f(int creg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6154 {
215
abfad046e6de *** empty log message ***
kono
parents: 214
diff changeset
6155 code_ll2f(creg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6156 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6157
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6158
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
6159 static void
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
6160 ladd(int creg,int reg,int dir) // creg=reg+dir
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6161 {
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
6162 printf("\taddic %s,%s,%d\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6163 lregister_name_low(creg),lregister_name_low(reg), dir);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
6164 printf("\tadd%s %s,%s\n", dir>0?"ze":"me",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6165 lregister_name_high(creg),lregister_name_high(reg));
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6166 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6167
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6168 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6169 code_lpreinc(int e1,int e2,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6170 {
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6171 int dreg,xreg;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6172 int dir=caddr(e1);
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6173 if (car(e2)==LREGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6174 use_longlong(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6175 ladd(cadr(e2),cadr(e2),dir);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
6176 if (reg!=cadr(e2)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6177 lmove(reg,cadr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6178 }
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6179 return;
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6180 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6181 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6182 if(!is_int_reg(creg)) error(-1);
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6183 emit_push();
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6184 if (reg==USE_CREG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6185 dreg=get_lregister(); if (!dreg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6186 set_lreg(dreg,0); // free old lreg==creg
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6187 } else {
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6188 dreg = reg;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6189 }
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6190 xreg = emit_pop(0);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6191 lload(xreg,dreg,0);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
6192 ladd(dreg,dreg,dir);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6193 code_lassign(xreg,dreg);
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6194 emit_pop_free(xreg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6195 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6196
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6197 void
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6198 code_lpostinc(int e1,int e2,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6199 {
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6200 int dreg,nreg,xreg;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6201 int dir=caddr(e1);
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6202 if (car(e2)==LREGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6203 use_longlong(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6204 if (use && reg!=cadr(e2))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6205 lmove(reg,cadr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6206 ladd(cadr(e2),cadr(e2),dir);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6207 return;
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6208 }
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6209 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6210 if(!is_int_reg(creg)) error(-1);
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6211 emit_push();
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6212 nreg=get_lregister(); if (!nreg) error(-1);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6213 if (reg==USE_CREG) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6214 dreg=get_lregister(); if (!dreg) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6215 set_lreg(dreg,0); // free old lreg==creg
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6216 } else {
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6217 dreg = reg;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6218 }
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6219 xreg = emit_pop(0);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6220 lload(xreg,dreg,0);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 271
diff changeset
6221 ladd(nreg,dreg,dir);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6222 code_lassign(xreg,nreg);
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
6223 emit_pop_free(xreg);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6224 free_register(nreg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6225 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6226
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6227 void
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6228 code_lassop(int op,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6229 {
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6230 int xreg;
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6231 int edx,edx0=-1;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6232
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6233 // (*creg) op = pop()
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6234 xreg = emit_lpop(0); /* pop e3 value */
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6235 if (!is_int_reg(creg)) error(-1);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6236 edx = ireg;
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
6237 emit_push();
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6238 use_longlong(reg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6239 if (regv_l(lreg)==edx || regv_h(lreg)==edx) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6240 // this can't happen
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6241 edx0 = get_register(); if(!edx0) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6242 printf("## lassop\n\tmr %s,%s\n",register_name(edx0),register_name(edx));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6243 edx = edx0;
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6244 }
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6245 lload(edx0=edx,reg,0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6246 ltosop(op,reg,xreg);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6247 use_reg(reg);
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
6248 edx = emit_pop(0);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6249 code_lassign(edx,reg);
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6250 if (edx0!=-1)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6251 free_register(edx0);
269
d9f4026de4e3 MIPS continue...
kono
parents: 268
diff changeset
6252 emit_pop_free(edx);
211
dbad3172fa14 *** empty log message ***
kono
parents: 210
diff changeset
6253 emit_lpop_free(xreg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6254 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6255
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
6256 void
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
6257 code_register_lassop(int reg,int op) {
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6258 // reg op = pop()
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
6259 int xreg=emit_lpop();
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6260 ltosop(op,reg,xreg);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6261 emit_lpop_free(xreg);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
6262 }
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
6263
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6264
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6265 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6266
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
6267 void
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
6268 code_save_stacks()
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
6269 {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
6270 int i,reg;
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6271 for(i=0;i<reg_sp;i++) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
6272 if ((reg=reg_stack[i])>=0) {
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6273 code_assign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
6274 (reg_stack[i]=new_lvar(SIZE_OF_INT)),reg,0);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6275 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6276 free_register(reg);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6277 }
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6278 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6279 #if FLOAT_CODE
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6280 for(i=0;i<freg_sp;i++) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
6281 if ((reg=freg_stack[i])>=0) {
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6282 code_dassign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
6283 (freg_stack[i]=new_lvar(SIZE_OF_DOUBLE)),reg,1);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6284 freg_stack[i]= freg_stack[i]-REG_LVAR_OFFSET;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6285 free_register(reg);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6286 }
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
6287 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6288 #endif
212
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6289 #if LONGLONG_CODE
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6290 for(i=0;i<lreg_sp;i++) {
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6291 if ((reg=lreg_stack[i])>=0) {
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
6292 code_lassign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
6293 (lreg_stack[i]=new_lvar(SIZE_OF_LONGLONG)),reg);
212
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6294 lreg_stack[i]= lreg_stack[i]-REG_LVAR_OFFSET;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6295 free_register(reg);
212
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6296 }
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6297 }
32f54ab63b35 *** empty log message ***
kono
parents: 211
diff changeset
6298 #endif
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6299 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6300
739
0c7a6ae119ba i64 continue... compiler compiled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 726
diff changeset
6301 static void
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6302 emit_lib(char *p[])
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
6303 {
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
6304 while(*p) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6305 printf("%s\n",*p++);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6306 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6307 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6308
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6309 void
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6310 code_closing()
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6311 {
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6312 #if FLOAT_CODE
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6313 if (d2u_lib_used) emit_lib(d2u_lib);
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6314 if (u2d_lib_used) emit_lib(u2d_lib);
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6315 if (float_one_lib_used) emit_lib(float_one_lib);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
6316 if (float_zero_lib_used) emit_lib(float_zero_lib);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
6317 if (i2d_lib_used) emit_lib(i2d_lib);
739
0c7a6ae119ba i64 continue... compiler compiled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 726
diff changeset
6318 d2u_lib_used = u2d_lib_used= float_one_lib_used= float_zero_lib_used = i2d_lib_used = 0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
6319 #endif
213
kono
parents: 212
diff changeset
6320 #if LONGLONG_CODE
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6321 if (asld_lib_used) emit_lib(asld_lib);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6322 if (lsrd_lib_used) emit_lib(lsrd_lib);
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6323 if (asrd_lib_used) emit_lib(asrd_lib);
739
0c7a6ae119ba i64 continue... compiler compiled.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 726
diff changeset
6324 asld_lib_used = lsrd_lib_used = asrd_lib_used = 0;
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6325 #if 0
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6326 if (lumod_lib_used) emit_lib(lumod_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6327 if (lmod_lib_used) emit_lib(lmod_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6328 if (ludiv_lib_used) emit_lib(ludiv_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6329 if (ldiv_lib_used) emit_lib(ldiv_lib);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
6330 #endif
213
kono
parents: 212
diff changeset
6331 #if FLOAT_CODE
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6332 #if 0
216
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6333 if (dl2ll_lib_used) emit_lib(dl2ll_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6334 if (d2ull_lib_used) emit_lib(d2ull_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6335 if (f2ll_lib_used) emit_lib(f2ll_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6336 if (f2ull_lib_used) emit_lib(f2ull_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6337 if (ll2d_lib_used) emit_lib(ll2d_lib);
941177f65d07 *** empty log message ***
kono
parents: 215
diff changeset
6338 if (ll2f_lib_used) emit_lib(ll2f_lib);
213
kono
parents: 212
diff changeset
6339 #endif
kono
parents: 212
diff changeset
6340 #endif
218
2d64e82437d2 *** empty log message ***
kono
parents: 217
diff changeset
6341 #endif
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6342 #ifndef __APPLE__
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6343 if (saveFP_used) emit_lib(saveFP_lib);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6344 #endif
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
6345 global_table();
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
6346 /* printf("\t.ident \"Micro-C compiled\"\n"); */
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
6347 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
6348
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6349 #if CASE_CODE
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6350
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6351 int
382
832e1f6bba82 ARM wrote all code. Check compile error.
kono
parents: 375
diff changeset
6352 code_table_jump_p(int delta) { return 1; }
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6353
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6354 void
302
bea7ab2fb218 switch table jump finished.
kono
parents: 300
diff changeset
6355 code_table_jump(int l,int csvalue,int delta,int max,int min,int dlabel)
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6356 {
302
bea7ab2fb218 switch table jump finished.
kono
parents: 300
diff changeset
6357 int t,s,u=-1;
bea7ab2fb218 switch table jump finished.
kono
parents: 300
diff changeset
6358 char *crn = register_name(csvalue); // can be t,s,u
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6359 char *trn = register_name(t=get_register());
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6360 char *srn = register_name(s=get_register());
302
bea7ab2fb218 switch table jump finished.
kono
parents: 300
diff changeset
6361 char *urn;
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6362
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6363 inc_cmpflag();
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6364 if (min>32767||min<-32765) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6365 if (t==csvalue) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6366 code_const(min,s);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6367 printf("\tsub\t%s,%s,%s\n",trn,crn,srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6368 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6369 code_const(min,t);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6370 printf("\tsub\t%s,%s,%s\n",trn,crn,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6371 }
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6372 } else {
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
6373 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6374 printf("\taddi\t%s,%s,lo16(%d)\n",trn,crn,-min);
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
6375 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6376 printf("\taddi\t%s,%s,%d@l\n",trn,crn,-min);
667
dbfbeb05210c *** empty log message ***
kono
parents: 664
diff changeset
6377 #endif
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6378 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6379 printf("\tcmplwi %s,%s,%d\n",crname(cmpflag),trn,max-min);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6380 printf("\tbgt-\t%s,%s%d\n",crname(cmpflag),lpfx,dlabel);
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6381 inc_cmpflag();
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6382 switch(delta) {
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6383 case 1: printf("\tslwi %s,%s,2\n",trn,trn); break;
302
bea7ab2fb218 switch table jump finished.
kono
parents: 300
diff changeset
6384 case 2:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6385 printf("\tli %s,1\n",srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6386 printf("\tand %s,%s,%s\n",srn,srn,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6387 printf("\tcmplwi %s,%s,0\n",crname(cmpflag),srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6388 printf("\tbne\t%s,%s%d\n",crname(cmpflag),lpfx,dlabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6389 printf("\tslwi %s,%s,1\n",trn,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6390 break;
302
bea7ab2fb218 switch table jump finished.
kono
parents: 300
diff changeset
6391 case 4:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6392 printf("\tli %s,3\n",srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6393 printf("\tand %s,%s,%s\n",srn,srn,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6394 printf("\tcmplwi %s,%s,0\n",crname(cmpflag),srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6395 printf("\tbne\t%s,%s%d\n",crname(cmpflag),lpfx,dlabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6396 break;
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6397 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6398 urn = register_name(u=get_register());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6399 printf("\tli %s,%d\n",srn,delta);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6400 printf("\tdivwu %s,%s,%s\n",urn,trn,srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6401 printf("\tmullw %s,%s,%s\n",srn,urn,srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6402 printf("\tsubf %s,%s,%s\n",srn,trn,srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6403 printf("\tcmplwi %s,%s,0\n",crname(cmpflag),srn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6404 printf("\tbne\t%s,%s%d\n",crname(cmpflag),lpfx,dlabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6405 printf("\tslwi %s,%s,2\n",trn,urn);
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6406 }
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6407 #ifdef __APPLE__
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6408 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6409 srn,l,code_base);
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6410 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6411 srn,l,code_base,srn);
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6412 printf("\tadd %s,%s,%s\n",trn,srn,trn);
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6413 printf("\tlwz r0,0(%s)\n",trn);
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6414 printf("\tadd r0,r0,%s\n",srn);
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6415 printf("\tmtctr r0\n");
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6416 printf("\tbctr\n");
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6417 #else
672
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
6418 printf("\tlis %s,%s%d@ha\n",srn,lpfx,l);
3f559c67bc86 *** empty log message ***
kono
parents: 667
diff changeset
6419 printf("\tla %s,%s%d@l(%s)\n",srn,lpfx,l,srn);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6420 printf("\tadd %s,%s,%s\n",trn,srn,trn);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6421 printf("\tlwz 0,0(%s)\n",trn);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6422 printf("\tadd 0,0,%s\n",srn);
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6423 printf("\tmtctr 0\n");
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6424 printf("\tbctr\n");
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6425 #endif
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6426
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6427 free_register(s);
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6428 free_register(t);
302
bea7ab2fb218 switch table jump finished.
kono
parents: 300
diff changeset
6429 if (u!=-1) free_register(u);
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6430 }
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6431
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6432 void
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6433 code_table_open(int l)
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6434 {
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6435 printf("\t.p2align 2\n");
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6436 fwddef(l);
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6437 }
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6438
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6439 void
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6440 code_table_value(int label,int table_top)
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6441 {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6442 printf("\t.long %s%d-%s%d\n",lpfx,label,lpfx,table_top);
300
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6443 }
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6444
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6445 void
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6446 code_table_close()
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6447 {
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6448 }
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6449
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6450 #endif
86255dd7f148 table done. (?)
kono
parents: 297
diff changeset
6451
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6452 #if ASM_CODE
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6453
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6454 /*
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6455 print an operand
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6456 */
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6457
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6458 static void
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6459 emit_asm_operand(int rstr)
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6460 {
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6461 if (car(rstr)==REGISTER) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6462 printf("%s",register_name(cadr(rstr)));
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6463 } else if (car(rstr)==CONST) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6464 printf("%d",cadr(rstr));
319
88cf6512fa1b asm for powerpc done.
kono
parents: 318
diff changeset
6465 } else if (car(rstr)==FNAME) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6466 printf("%s",ncaddr(rstr)->nm);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
6467 } else if (car(rstr)==LABEL) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6468 printf("%s%d:\n",lpfx,cadr(rstr));
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6469 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6470 error(-1);
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6471 }
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6472 }
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6473
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6474 /*
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6475 prepare asm operands
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6476
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6477 char *constraints sgtring
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
6478 int oeprand expr
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6479 int mode (ASM_INPUT,ASM_OUTPUT)
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6480 int replacement list
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6481 int output operands count
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6482 int output operands replacement list
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6483
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6484 retrun replacement list
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6485 list3( operands, next, clobber )
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6486 0 can be shared in input/output
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6487 1 can't be used in input
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6488 */
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6489
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
6490 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
6491 code_asm_operand(char *p,int e1,int mode,int repl,int n,int repl0)
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6492 {
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6493 int r;
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6494 int c;
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6495 int val;
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6496 int clobber = 0;
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6497
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6498 printf("## constraint %s\n",p);
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6499 retry:
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6500 switch((c=*p)) {
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6501 case '?':
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6502 case '!':
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6503 case '+':
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6504 case '%':
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6505 case '#':
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6506 case '*':
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6507 case '=':
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6508 // output register
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6509 p++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6510 goto retry;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6511 case '&':
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6512 // earlyclobber
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6513 p++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6514 clobber = 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6515 goto retry;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6516 case 'b': // address base register (what?)
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6517 case 'r':
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6518 if (mode==ASM_INPUT) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6519 for(;repl0;repl0 = cadr(repl0)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6520 if (car(car(repl0))==REGISTER && caddr(repl0)==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6521 r = cadr(car(repl0));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6522 caddr(repl0) = ASM_USED;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6523 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6524 }
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6525 }
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6526 r = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6527 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6528 r = get_register();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6529 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6530 repl = list3(list2(REGISTER,r),repl,clobber);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6531 break;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6532 case 'm':
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6533 repl = list3(list2(0,0),repl,clobber);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6534 break;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6535 case 'i':
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6536 if (car(e1)==GVAR) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6537 e1=list3n(FNAME,0,ncaddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6538 } else if (car(e1)==FNAME) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6539 e1=list3n(FNAME,0,ncaddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6540 } else if (car(e1)==STRING) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6541 val = emit_string_label();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6542 ascii(ncaddr(e1)->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6543 e1=list2(LABEL,val);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6544 } else if (car(e1)==CONST) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6545 } else error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6546 repl = list3(e1,repl,clobber);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6547 break;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6548 case '0': case '1': case '2': case '3': case '4':
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6549 case '5': case '6': case '7': case '8': case '9':
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6550 val = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6551 do { val = val*10 + c-'0'; } while (digit(c=*p++));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6552 if (val>MAX_ASM_REG) error(-1); // too large register
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6553 if (n-val<0) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6554 repl = list3(car(nth(n-val-1,repl0)),repl,clobber);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6555 break;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6556 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6557 printf("### unknown asm constraint %c\n",c);
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6558 }
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6559 return repl;
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6560 }
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6561
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6562 void
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
6563 code_free_asm_operand(int repl)
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6564 {
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6565 for(;repl;repl=cadr(repl)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6566 if (car(car(repl))==REGISTER)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6567 free_register(cadr(car(repl)));
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6568 }
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6569 }
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6570
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6571
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6572 extern void
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
6573 code_asm(char *asm_str,int repl)
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6574 {
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6575 int c,i,rstr,val;
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6576 char *p;
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6577 int reg[MAX_ASM_REG];
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6578
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
6579 text_mode(0);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6580 c = *asm_str;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6581 if (c!='\t'&&c!=' ') printf("\t");
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6582 for(i=0;repl && i<MAX_ASM_REG;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6583 reg[i] = car(repl);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6584 repl = cadr(repl);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6585 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6586 p = asm_str;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6587 while((c = *p++)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6588 if (c=='%') {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6589 c = *p++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6590 if (!c) { break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6591 } else if (c=='%') {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6592 printf("%%"); continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6593 } else if (!digit(c)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6594 printf("%%%c",c); continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6595 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6596 val = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6597 do { val = val*10 + c-'0'; } while (digit(c=*p++)) ;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6598 p--;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6599 if (val>MAX_ASM_REG) error(-1); // too large register
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6600 rstr = reg[val];
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6601 emit_asm_operand(rstr);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6602 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6603 printf("%c",c);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6604 }
318
9fe0b32a7d57 asm continue...
kono
parents: 316
diff changeset
6605 }
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 319
diff changeset
6606 printf("\n");
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6607 }
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6608
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6609 #endif
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6610
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
6611
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6612 #if BIT_FIELD_CODE
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6613
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6614 /* bit field alignment calcuration */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6615
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6616 static void
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6617 set_bitsz(int type,int *pbitpos,int *pbitsize,
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6618 int *psign,int *pbitsz,int *palign,int *pl)
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6619 {
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
6620 int sign=0,bitsz=0;
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
6621 int align=4,l=0;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6622 *pbitpos = cadr(caddr(type));
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6623 *pbitsize = caddr(caddr(type));
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 418
diff changeset
6624 switch(cadr(type)) { /* value type */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6625 case INT: sign=1; bitsz=32; align=4;break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6626 case UNSIGNED: bitsz=32; align=4;break;
335
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
6627 case CHAR: sign=1; bitsz= 8; align=1;break;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6628 case UCHAR: bitsz= 8; align=1;break;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6629 case SHORT: sign=1; bitsz=16; align=2;break;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6630 case USHORT: sign=1; bitsz=16; align=2;break;
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
6631 #ifdef __APPLE__
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6632 case LONGLONG: sign=1; bitsz=64; align=4;l=1; break;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6633 case ULONGLONG: bitsz=64; align=4;l=1; break;
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
6634 #else
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
6635 case LONGLONG: sign=1; bitsz=64; align=8;l=1; break;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6636 case ULONGLONG: bitsz=64; align=8;l=1; break;
676
5e71527f9fd6 *** empty log message ***
kono
parents: 674
diff changeset
6637 #endif
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6638 default: error(-1);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6639 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6640 *psign = sign;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6641 *pbitsz = bitsz;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6642 *palign = align;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6643 *pl = l;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6644 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6645
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6646 /*
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6647 bit field alignment calcuration
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6648 this is architecture depenedent
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6649 */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6650
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6651 extern int
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6652 code_bit_field_disp(int type,int *poffset,int *bfd,int *sz)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6653 {
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
6654 int sign,bitsz,align;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6655 int i;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6656 int bitpos = *bfd;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6657 int bitpos0;
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6658 int bitsize;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6659 int offset = *poffset;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6660 int l;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6661 set_bitsz(type,&bitpos0,&bitsize,&sign,&bitsz,&align,&l);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6662
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
6663 if (bitsize>bitsz) { error(BTERR); bitsize = bitsz; }
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6664
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6665 /* bfd means previous bit field bit offset */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6666 if (bitpos) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6667 /* previous field is bit field and spaces may remain */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6668 /* calc previsous offset */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6669
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6670 i= offset-(bitpos+7)/8;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6671
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6672 for(l = bitpos;l>0;l -= 8,i++) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6673 if ((i & (align-1))==0 && l+bitsize <= bitsz) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6674 /* alignment is correct and space remains */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6675 *poffset=offset=i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6676 i = l+bitsize;
423
8b9136a06f56 bitfield continue...
kono
parents: 420
diff changeset
6677 *bfd = (i==bitsz)?0:i;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6678 *sz = (i+7)/8;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6679 // printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",l,bitsize,bitsz,*poffset);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6680 return l;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6681 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6682 }
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6683 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6684
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6685 /* first bit-field */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6686
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6687 if ((i=(offset & (align-1)))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6688 *poffset = (offset += (align-i));
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6689 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6690 bitpos = 0;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6691 *bfd = (bitsize==bitsz)?0:bitsize;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6692 *sz = (bitsize+7)/8;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6693
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6694 // printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",bitpos,bitsize,bitsz,*poffset);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6695 return bitpos;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6696 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6697
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6698 /* bit field value */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6699
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6700 extern void
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6701 code_bit_field(int type,int adr, int reg)
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6702 {
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
6703 int sign,bitsz,l,align;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6704 int bitsize,bitpos;
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6705 int i,size;
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6706 set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6707 size = bitsz/8;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6708 // printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6709 /* this implementation returns -1 for int i:1; */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6710 if (l==1) {
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
6711 #if LONGLONG_CODE
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6712 // use_int(adr);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6713 use_longlong(reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6714 lload(adr,reg,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6715 /* shift left */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6716 if (bitpos)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6717 loprtc(LLSHIFT,reg,list2(CONST,bitpos));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6718 /* shift right */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6719 if ((i=bitsz-bitsize))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6720 loprtc(sign?LRSHIFT:LURSHIFT,reg,list2(CONST,i));
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
6721 #endif
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6722 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6723 // use_int(adr);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6724 use_int(reg);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6725 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6726 printf("\t%s %s,lo16(%d)(%s)\n",cload(size),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6727 register_name(reg),0,register_name(adr));
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6728 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6729 printf("\t%s %s,%d@l(%s)\n",cload(size),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6730 register_name(reg),0,register_name(adr));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6731 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6732 cext(sign,size,reg);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6733 /* shift left */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6734 if ((i=bitpos+(32-bitsz)))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6735 oprtc(LSHIFT,reg,list2(CONST,i));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6736 /* shift right */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6737 if ((i=bitsz-bitsize+(32-bitsz)))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6738 oprtc(sign?RSHIFT:URSHIFT,reg,list2(CONST,i));
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6739 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6740 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6741
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6742 /* bit field replacement */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6743
330
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6744 static void
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
6745 make_mask_and_or(int mask,int tmp,char *trn,char *crn,char *lrn)
330
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6746 {
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6747 // printf("## mask 0x%08x ~0x%08x\n",mask,~mask);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6748 code_const(~mask,tmp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6749 printf("\tor %s,%s,%s\n",trn,crn,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6750 /* do conjunction */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6751 printf("\tand %s,%s,%s\n",lrn,trn,lrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6752 /* make or-mask */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6753 code_const(mask,tmp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6754 printf("\tand %s,%s,%s\n",trn,crn,trn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6755 /* do disjunction */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6756 printf("\tor %s,%s,%s\n",crn,trn,lrn);
330
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6757 }
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6758
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6759 extern void
431
800a5e3e6a17 *** empty log message ***
kono
parents: 426
diff changeset
6760 code_bit_replace(int adr,int value,int type)
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6761 {
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
6762 int sign,bitsz,l,align;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6763 int bitsize,bitpos;
330
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6764 int mask = 0;
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6765 int tmp = -1;
331
f25aa4f03198 bit-field continue...
kono
parents: 330
diff changeset
6766 int i;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6767 int lvalue;
330
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6768 char *crn,*lrn,*trn;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6769 int size;
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6770 set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6771 size = bitsz/8;
467
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
6772 // printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6773 if (l) {
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
6774 #if LONGLONG_CODE
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6775 // use_int(adr);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6776 lvalue = get_lregister();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6777 lload(adr,lvalue,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6778 use_longlong(value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6779 crn = lregister_name_low(value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6780 lrn = lregister_name_low(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6781 /* shift left */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6782 if ((i=bitsz-bitsize-bitpos))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6783 loprtc(LLSHIFT,value,list2(CONST,i));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6784 trn = register_name(tmp = get_register());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6785 if (bitpos+bitsize>=32) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6786 /* make and-mask lower */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6787 mask = make_mask(bitpos>=32?bitpos-32:0,bitpos+bitsize-32-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6788 make_mask_and_or(mask,tmp,trn,crn,lrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6789 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6790 crn = lregister_name_high(value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6791 lrn = lregister_name_high(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6792 if (bitpos<32) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6793 /* make and-mask upper */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6794 mask = make_mask(bitpos,bitpos+bitsize>=32?31:bitpos+bitsize-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6795 make_mask_and_or(mask,tmp,trn,crn,lrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6796 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6797 code_lassign(adr,value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6798 free_register(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6799 // free_register(adr);
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
6800 #endif
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6801 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6802 // use_int(adr);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6803 use_int(value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6804 lvalue = get_register();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6805 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6806 printf("\t%s %s,lo16(%d)(%s)\n",cload(size),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6807 register_name(lvalue),0,register_name(adr));
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6808 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6809 printf("\t%s %s,%d@l(%s)\n",cload(size),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6810 register_name(lvalue),0,register_name(adr));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6811 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6812 cext(sign,size,lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6813 crn = register_name(value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6814 lrn = register_name(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6815 /* shift left */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6816 if ((i=bitsz-bitsize-bitpos))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6817 oprtc(LSHIFT,value,list2(CONST,i));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6818 trn = register_name(tmp = get_register());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6819 /* make and-mask */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6820 mask = make_mask(bitpos+(32-bitsz),bitpos+bitsize-1+(32-bitsz));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6821 make_mask_and_or(mask,tmp,trn,crn,lrn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6822 free_register(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6823 code_assign(adr,size,value);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6824 }
330
fa4c7b15d7ed bit field all code written
kono
parents: 329
diff changeset
6825 if (tmp!=-1) free_register(tmp);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6826 if (use) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6827 code_bit_field(type,adr,USE_CREG);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6828 }
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6829 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6830
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6831 static void
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6832 make_mask_and_or_const(int mask,char *crn,int c)
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6833 {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6834 char *trn;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6835 int tmp = -1;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
6836 // printf("## mask 0x%08x ~0x%08x\n",mask,~mask);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6837 if ((~mask|c)!=-1) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6838 trn = register_name(tmp=get_register());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6839 code_const((~mask|c),tmp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6840 /* do conjunction */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6841 printf("\tand %s,%s,%s\n",crn,trn,crn);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6842 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6843 /* make or-mask */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6844 c = mask&c;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6845 if (c!=0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6846 /* do disjunction */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6847 if (!((mask&c)&0xffff0000)) {
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6848 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6849 printf("\tori %s,%s,lo16(%d)\n",crn,crn,c);
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6850 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6851 printf("\tori %s,%s,%d@l\n",crn,crn,c);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6852 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6853 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6854 trn = register_name(tmp=get_register());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6855 code_const(c,tmp);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6856 printf("\tor %s,%s,%s\n",crn,trn,crn);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6857 }
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6858 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6859 if (tmp!=-1) free_register(tmp);
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6860 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6861
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6862 extern void
431
800a5e3e6a17 *** empty log message ***
kono
parents: 426
diff changeset
6863 code_bit_replace_const(int value,int adr,int type)
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6864 {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6865 int sign,bitsz,l,align;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6866 int bitsize,bitpos,size;
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6867 int mask = 0;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6868 int i;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6869 int c;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6870 int lvalue;
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6871 #if LONGLONG_CODE
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6872 long long lc;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6873 #endif
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6874 char *crn;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6875 set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6876 size = bitsz/8;
467
32737bad7489 fix list/tag interference
kono
parents: 463
diff changeset
6877 // printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6878 if (l) {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6879 #if LONGLONG_CODE
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6880 use_int(adr);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6881 lvalue = get_lregister();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6882 lload(adr,lvalue,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6883 crn = lregister_name_low(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6884 /* shift left */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6885 lc = lcadr(value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6886 if ((i=bitsz-bitsize-bitpos))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6887 lc <<= i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6888 if (bitpos+bitsize>=32) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6889 /* make and-mask lower */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6890 mask = make_mask(bitpos>=32?bitpos-32:0,bitpos+bitsize-32-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6891 make_mask_and_or_const(mask,crn,(int)lc);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6892 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6893 crn = lregister_name_high(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6894 if (bitpos<32) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6895 /* make and-mask upper */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6896 mask = make_mask(bitpos,bitpos+bitsize>=32?31:bitpos+bitsize-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6897 make_mask_and_or_const(mask,crn,(int)(lc>>32));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6898 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6899 code_lassign(adr,lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6900 free_register(lvalue);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6901 #endif
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6902 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6903 use_int(adr);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6904 lvalue = get_register();
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6905 #ifdef __APPLE__
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6906 printf("\t%s %s,lo16(%d)(%s)\n",cload(size),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6907 register_name(lvalue),0,register_name(adr));
662
c9df4e08da9b *** empty log message ***
kono
parents: 660
diff changeset
6908 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6909 printf("\t%s %s,%d@l(%s)\n",cload(size),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6910 register_name(lvalue),0,register_name(adr));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6911 #endif
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6912 cext(sign,size,lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6913 crn = register_name(lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6914 /* shift left */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6915 c = cadr(value);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6916 if ((i=bitsz-bitsize-bitpos))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6917 c <<= i;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6918 /* make and-mask */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6919 mask = make_mask(bitpos+(32-bitsz),bitpos+bitsize-1+(32-bitsz));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6920 make_mask_and_or_const(mask,crn,c);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6921 code_assign(adr,size,lvalue);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6922 free_register(lvalue);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6923 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 423
diff changeset
6924 if (use) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 845
diff changeset
6925 code_bit_field(type,adr,USE_CREG);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6926 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6927 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
6928
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6929 #endif
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
6930
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6931 extern int
782
003067098032 code argument offset in caller and callee
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 780
diff changeset
6932 code_arg_alignment(int args,NMTBL *n, int type0,int sz, int is_code)
003067098032 code argument offset in caller and callee
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 780
diff changeset
6933 {
003067098032 code argument offset in caller and callee
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 780
diff changeset
6934 return code_arg_alignment0(args,n, type0,sz, is_code);
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6935 }
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6936
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6937
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6938 extern int
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6939 code_lvar_alignment(int args,NMTBL *n, int type0,int sz)
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6940 {
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6941 return code_lvar_alignment0(args,n, type0,sz);
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6942 }
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6943
83e18db76c96 architecture depenedent argument alignment
kono
parents: 712
diff changeset
6944
89
917947ffeb7c power pc version
kono
parents:
diff changeset
6945 /* end */