annotate mc-codegen.c @ 330:fa4c7b15d7ed

bit field all code written
author kono
date Wed, 23 Jun 2004 17:12:33 +0900
parents 4c8f8ef8c0cf
children f25aa4f03198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
e5d40f8c4cce bit-field continue.
kono
parents: 320
diff changeset
1 /* Micro-C Generic Code Generation Part */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2 /* $Id$ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4 #include <stdio.h>
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
5 #include "mc.h"
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
6 #include "mc-parse.h"
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
7 #include "mc-codegen.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
8 #include "mc-code.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
9
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
10 int use; /* generated value will be used */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
11 char *init_src;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
12 int size_of_int;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
13 int size_of_short;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
14 int size_of_float;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
15 int size_of_double;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
16 int size_of_longlong;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
17 int bit_of_byte;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
18 int endian;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
19
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
20 static void assign(int e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
21 static void gen_asm(int asm0,int in,int out,int opt,int e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
22 static void compatible(int t1, int t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
23 static int contains(int e,int type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
24 static int contains_in_list(int e,int type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
25 static int contains_in_list_p(int e,int (*p)(int));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
26 static void iassop(int e1);
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
27 static int is_same_type(int e1,int e2);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
28 static void jump(int e1, int env);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
29 static void machinop(int e1);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
30 static int register_to_lvar(int e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
31 static void remove0(int *parent,int e) ;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
32 static void sassign(int e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
33
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
34 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
35
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
36 /* floating point */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
37
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
38 static void dassop(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
39 static void dmachinop(int e1,int d);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
40 static void dassign(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
41
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
42 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
43 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
44 static void lassop(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
45 static void lmachinop(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
46 static void lassign(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
47 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
48
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
49 #if BIT_FIELD_CODE
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
50 static int bit_field(int e1,int t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
51 static int bassign(int e1,int e2,int t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
52 static int bassop(int e1,int e2,int op,int t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
53 #endif
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
54
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
55
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
56 extern void
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
57 codegen_init()
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
58 {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
59 /* called only once */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
60 code_init();
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
61 }
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
62
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
63 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
64 codegen_reinit()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
65 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
66 /* called for each file */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
67 emit_reinit();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
68 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
69
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
70 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
71 codegen_decl_init()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
72 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
73 /* called before each declaration */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
74 emit_init();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
75 init_free_lvar_list();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
76 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
77
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
78 extern void
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
79 arg_register(NMTBL *fnptr)
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
80 {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
81 code_arg_register(fnptr);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
82 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
83
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
84 extern int
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
85 gexpr(int e1,int use0)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
86 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
87 if (chk) return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
88 gexpr_init();
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
89 use = use0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
90 #if 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
91 if(lineno==2862) {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
92 return g_expr0(e1); /*break here*/
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
93 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
94 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
95 return g_expr0(e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
96 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
97
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
98 /* gexpr for value unused */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
99
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
100 extern int
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
101 g_expr_u(int e1)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
102 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
103 int t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
104 int suse = use; use=0;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
105 t=g_expr0(e1);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
106 code_gexpr(e1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
107
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
108 use=suse;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
109 return t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
110 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
111
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
112 /* gexpr for value used */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
113
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
114 extern int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
115 g_expr(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
116 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
117 int t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
118 int suse = use; use=1;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
119 t=g_expr0(e1);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
120 code_gexpr(e1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
121
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
122 use=suse;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
123 return t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
124 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
125
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
126 /* gexpr for used flag untouched */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
127
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
128 extern int
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
129 g_expr0(int e1)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
130 {
191
8646a4a9cde9 *** empty log message ***
kono
parents: 189
diff changeset
131 int e2,e3,t,d,t1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
132 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
133
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
134 code_gexpr(e1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
135
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
136 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
137 switch (car(e1)){
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
138 case GVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
139 code_gvar(e1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
140 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
141 case RGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
142 code_rgvar(e1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
143 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
144 case CRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
145 code_crgvar(e1,USE_CREG,1,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
146 return CHAR;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
147 case CURGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
148 code_crgvar(e1,USE_CREG,0,1);
165
kono
parents: 164
diff changeset
149 return UCHAR;
kono
parents: 164
diff changeset
150 case SRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
151 code_crgvar(e1,USE_CREG,1,size_of_short);
165
kono
parents: 164
diff changeset
152 return CHAR;
kono
parents: 164
diff changeset
153 case SURGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
154 code_crgvar(e1,USE_CREG,0,size_of_short);
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
155 return UCHAR;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
156 case LVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
157 code_lvar(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
158 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
159 case REGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
160 code_register(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
161 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
162 #if FLOAT_CODE
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
163 case DREGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
164 code_dregister(e2,USE_CREG,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
165 return DOUBLE;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
166 case FREGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
167 code_dregister(e2,USE_CREG,0);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
168 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
169 #endif
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
170 #if LONGLONG_CODE
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
171 case LREGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
172 code_lregister(e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
173 return LONGLONG;
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
174 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
175 case RLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
176 code_rlvar(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
177 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
178 case CRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
179 code_crlvar(e2,USE_CREG,1,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
180 return CHAR;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
181 case CURLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
182 code_crlvar(e2,USE_CREG,0,1);
165
kono
parents: 164
diff changeset
183 return UCHAR;
kono
parents: 164
diff changeset
184 case SRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
185 code_crlvar(e2,USE_CREG,1,size_of_short);
165
kono
parents: 164
diff changeset
186 return CHAR;
kono
parents: 164
diff changeset
187 case SURLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
188 code_crlvar(e2,USE_CREG,0,size_of_short);
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
189 return UCHAR;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
190 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
191 case FRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
192 code_drlvar(e2,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
193 return FLOAT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
194 case FRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
195 code_drgvar(e1,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
196 return FLOAT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
197 case DRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
198 code_drlvar(e2,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
199 return DOUBLE;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
200 case DRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
201 code_drgvar(e1,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
202 return DOUBLE;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
203 #endif
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
204 #if LONGLONG_CODE
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
205 case LRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
206 code_lrlvar(e2,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
207 return LONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
208 case LRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
209 code_lrgvar(e1,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
210 return LONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
211 case LURLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
212 code_lrlvar(e2,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
213 return ULONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
214 case LURGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
215 code_lrgvar(e1,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
216 return ULONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
217 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
218 case FNAME:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
219 code_fname((NMTBL *)(e2),USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
220 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
221 case CONST: /* ÂåÆþ¤¹¤ëÃͤ¬0¤Ç¤âÆÃÊ̤ʽèÍý¤Ï¤·¤Ê¤¤ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
222 code_const(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
223 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
224 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
225 case DCONST:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
226 code_dconst(e1,USE_CREG,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
227 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
228 case FCONST:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
229 code_dconst(e1,USE_CREG,0);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
230 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
231 #endif
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
232 #if LONGLONG_CODE
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
233 case LCONST:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
234 code_lconst(e1,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
235 return LONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
236 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
237 case STRING:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
238 code_string(e1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
239 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
240 case FUNCTION:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
241 t = function(e1);
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
242 return t;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
243 case CODE:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
244 jump(e2,caddr(e1));
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
245 return VOID;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
246 case INDIRECT:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
247 return g_expr0(e2);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
248 case RINDIRECT:
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
249 return code_rindirect(e2,USE_CREG,caddr(e1),1);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
250 case URINDIRECT:
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
251 return code_rindirect(e2,USE_CREG,caddr(e1),0);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
252 case CRINDIRECT:
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
253 return code_crindirect(e2,USE_CREG,caddr(e1),1);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
254 case CURINDIRECT:
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
255 return code_crindirect(e2,USE_CREG,caddr(e1),0);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
256 case SRINDIRECT:
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
257 return code_srindirect(e2,USE_CREG,caddr(e1),1);
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
258 case SURINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
259 return code_srindirect(e2,USE_CREG,caddr(e1),0);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
260 #if FLOAT_CODE
197
b5f49f32c2ee *** empty log message ***
kono
parents: 196
diff changeset
261 case FRINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
262 return code_drindirect(e2,USE_CREG,caddr(e1),0);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
263 case DRINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
264 return code_drindirect(e2,USE_CREG,caddr(e1),1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
265 #endif
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
266 #if LONGLONG_CODE
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
267 case LRINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
268 return code_lrindirect(e2,USE_CREG,caddr(e1),0);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
269 case LURINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
270 return code_lrindirect(e2,USE_CREG,caddr(e1),1);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
271 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
272 case ADDRESS:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
273 if (car(e2)==REGISTER||car(e2)==DREGISTER||car(e2)==FREGISTER)
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
274 return register_to_lvar(e2); /* too late? */
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
275 else
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
276 return g_expr0(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
277 case MINUS: /* ¥ì¥¸¥¹¥¿¤ËÂФ·¡¢negl¤ò¼Â¹Ô¤¹¤ì¤Ð¼Â¸½²Äǽ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
278 g_expr0(e2); code_neg(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
279 return INT;
212
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
280 #if LONGLONG_CODE
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
281 case LMINUS:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
282 g_expr0(e2); code_lneg(USE_CREG);
212
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
283 return LONGLONG;
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
284 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
285 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
286 case DMINUS:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
287 g_expr0(e2); code_dneg(USE_CREG,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
288 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
289 case FMINUS:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
290 g_expr0(e2); code_dneg(USE_CREG,0);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
291 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
292 #endif
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
293 case CONV:
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
294 g_expr0(e2);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
295 switch(caddr(e1)) {
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
296 #if FLOAT_CODE
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
297 case I2D: code_i2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
298 case D2I: code_d2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
299 case U2D: code_u2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
300 case F2U: code_f2u(USE_CREG); return UNSIGNED;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
301 case I2F: code_i2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
302 case F2I: code_f2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
303 case U2F: code_u2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
304 case D2U: code_d2u(USE_CREG); return UNSIGNED;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
305 case D2F: code_d2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
306 case F2D: code_f2d(USE_CREG); return DOUBLE;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
307 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
308 #if LONGLONG_CODE
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
309 case I2LL: code_i2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
310 case I2ULL: code_i2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
311 case U2LL: code_u2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
312 case U2ULL: code_u2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
313 case LL2I: code_ll2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
314 case LL2U: code_ll2u(USE_CREG); return UNSIGNED;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
315 case ULL2I: code_ull2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
316 case ULL2U: code_ull2u(USE_CREG); return UNSIGNED;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
317 #if FLOAT_CODE
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
318 case D2LL: code_d2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
319 case D2ULL: code_d2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
320 case F2LL: code_f2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
321 case F2ULL: code_f2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
322 case LL2D: code_ll2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
323 case LL2F: code_ll2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
324 case ULL2D: code_ull2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
325 case ULL2F: code_ull2f(USE_CREG); return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
326 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
327 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
328
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
329 default:
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
330 error(-1); return INT;
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
331 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
332 case BNOT: /* ~ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
333 g_expr0(e2); code_not(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
334 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
335 case LNOT: /* ! */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
336 g_expr0(e2); code_lnot(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
337 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
338 case PREINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
339 code_preinc(e1,e2,caddr(e1),1,cadddr(e1),USE_CREG);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
340 return INT;
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
341 case UPREINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
342 code_preinc(e1,e2,caddr(e1),0,cadddr(e1),USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
343 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
344 case POSTINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
345 code_postinc(e1,e2,caddr(e1),1,cadddr(e1),USE_CREG);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
346 return INT;
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
347 case UPOSTINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
348 code_postinc(e1,e2,caddr(e1),0,cadddr(e1),USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
349 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
350 #if FLOAT_CODE
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
351 case DPREINC: /* ++d */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
352 code_dpreinc(e1,e2,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
353 return DOUBLE;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
354 case DPOSTINC: /* d++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
355 code_dpostinc(e1,e2,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
356 return DOUBLE;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
357 case FPREINC: /* ++f */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
358 code_dpreinc(e1,e2,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
359 return FLOAT;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
360 case FPOSTINC: /* f++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
361 code_dpostinc(e1,e2,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
362 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
363 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
364 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
365 case LPREINC: /* ++d */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
366 code_lpreinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
367 return LONGLONG;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
368 case LPOSTINC: /* d++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
369 code_lpostinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
370 return LONGLONG;
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
371 case LUPREINC: /* ++d */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
372 code_lpreinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
373 return ULONGLONG;
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
374 case LUPOSTINC: /* d++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
375 code_lpostinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
376 return ULONGLONG;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
377 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
378 case MUL: case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
379 case DIV: case UDIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
380 case MOD: case UMOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
381 case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT:
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
382 case ADD: case SUB: case BAND: case EOR: case BOR: case CMP: case CMPGE:
278
5b50813d0c45 MIPS 90% test passed. Self compile core dumped.
kono
parents: 277
diff changeset
383 case UCMP: case CMPEQ: case CMPNEQ: case UCMPGE:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
384 machinop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
385 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
386 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
387 case DMUL: case DDIV:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
388 case DADD: case DSUB:
250
7637295c4fb8 *** empty log message ***
kono
parents: 249
diff changeset
389 case DCMP: case DCMPGE: case DCMPEQ: case DCMPNEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
390 dmachinop(e1,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
391 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
392 case FMUL: case FDIV:
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
393 case FADD: case FSUB:
250
7637295c4fb8 *** empty log message ***
kono
parents: 249
diff changeset
394 case FCMP: case FCMPGE: case FCMPEQ: case FCMPNEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
395 dmachinop(e1,0);
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
396 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
397 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
398 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
399 case LMUL: case LUMUL:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
400 case LDIV: case LUDIV:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
401 case LMOD: case LUMOD:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
402 case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
403 case LADD: case LSUB: case LBAND: case LEOR: case LBOR: case LCMP:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
404 lmachinop(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
405 return INT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
406 #endif
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
407 case LCOND:
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
408 case DCOND:
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
409 case FCOND:
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
410 case COND: /* a?0:1 should consider non-brach instruction */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
411 d = (car(e1)==LCOND?LONGLONG:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
412 car(e1)==COND?INT:car(e1)==DCOND?DOUBLE:FLOAT);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
413 e2=fwdlabel();
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
414 b_expr(cadr(e1),0,e2,0);
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
415 g_expr0(caddr(e1));
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
416 t = code_get_fixed_creg(USE_CREG,d);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
417 jmp(e3=fwdlabel());
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
418 fwddef(e2);
191
8646a4a9cde9 *** empty log message ***
kono
parents: 189
diff changeset
419 t1=g_expr0(cadddr(e1));
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
420 code_set_fixed_creg(t,1,d);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
421 fwddef(e3);
191
8646a4a9cde9 *** empty log message ***
kono
parents: 189
diff changeset
422 return t1;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
423 case STASS:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
424 sassign(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
425 return RSTRUCT;
165
kono
parents: 164
diff changeset
426 case ASS: case CASS: case SASS:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
427 assign(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
428 return INT;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
429 case ASSOP: case CASSOP: case CUASSOP:
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
430 iassop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
431 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
432 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
433 case FASS: case DASS:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
434 dassign(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
435 return DOUBLE;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
436 case DASSOP: case FASSOP:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
437 dassop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
438 return DOUBLE;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
439 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
440 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
441 case LASS:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
442 lassign(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
443 return LONGLONG;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
444 case LASSOP: case LUASSOP:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
445 lassop(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
446 return LONGLONG ;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
447 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
448 case RSTRUCT:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
449 g_expr0(e2);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
450 return RSTRUCT;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
451 case ALLOCA:
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
452 code_alloca(e2,USE_CREG);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
453 return list2(POINTER,CHAR);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
454 case COMMA:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
455 g_expr_u(e2);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
456 return g_expr0(caddr(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
457 case RETURN:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
458 n = (NMTBL *)e2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
459 if (retcont==0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
460 retcont=fwdlabel();
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
461 code_return(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
462 return VOID;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
463 case ENVIRONMENT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
464 code_environment(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
465 return ADDRESS;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
466 #if BIT_FIELD_CODE
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
467 case RBIT_FIELD:
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
468 return bit_field(e2,caddr(e1) /* type */);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
469 case BASS:
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
470 return bassign(e2,caddr(e1),cadr(cadddr(e1))/* type */);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
471 case BASSOP:
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
472 return bassop(e2,caddr(e1),car(cadddr(e1)),/* op */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
473 cadr(cadddr(e1))/* type */);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
474 case BFD_REPL:
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
475 return bit_field_repl(e2,caddr(e1),cadddr(e1) /* type */);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
476 #endif
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
477 #if ASM_CODE
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
478 case ASM:
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
479 gen_asm(car(e2),cadr(e2),caddr(e2),cadddr(e2),caddr(e1));
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
480 /* asm in (str) out (str) opt(str) expr */
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
481 return VOID;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
482 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
483 default:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
484 code_bool(e1,USE_CREG); /* type? */
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
485 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
486 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
487 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
488
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
489 #define dual_ops(op) \
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
490 (op==GT|| op==UGT|| op==GE|| op==UGE|| op==LT|| \
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
491 op==ULT|| op==LE|| op==ULE|| \
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
492 op==DOP+GT|| op==DOP+GE|| op==DOP+LT|| op==DOP+LE || \
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
493 op==FOP+GT|| op==FOP+GE|| op==FOP+LT|| op==FOP+LE || \
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
494 op==FOP+EQ|| op==FOP+NEQ || \
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
495 op==EQ|| op==NEQ|| op==DOP+EQ|| op==DOP+NEQ)
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
496
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
497 static int
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
498 rop_dual(op)
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
499 {
232
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
500 // x op y => y dual(op) x
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
501 switch(op) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
502 case GT: return LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
503 case UGT: return ULT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
504 case GE: return LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
505 case UGE: return ULE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
506 case LT: return GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
507 case ULT: return UGT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
508 case LE: return GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
509 case ULE: return UGE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
510 case DOP+GT: return DOP+LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
511 case DOP+GE: return DOP+LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
512 case DOP+LT: return DOP+GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
513 case DOP+LE: return DOP+GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
514 case FOP+GT: return FOP+LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
515 case FOP+GE: return FOP+LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
516 case FOP+LT: return FOP+GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
517 case FOP+LE: return FOP+GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
518
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
519 case LOP+GT: return LOP+LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
520 case LOP+GE: return LOP+LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
521 case LOP+LT: return LOP+GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
522 case LOP+LE: return LOP+GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
523 case LOP+UGT: return FOP+ULT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
524 case LOP+UGE: return FOP+ULE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
525 case LOP+ULT: return FOP+UGT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
526 case LOP+ULE: return FOP+UGE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
527 }
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
528 return op;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
529 }
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
530
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
531 /* bexpr for value unused */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
532
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
533 extern void
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
534 bexpr_u(int e1, char cond, int l1)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
535 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
536 int op = car(e1);
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
537 if (chk) return;
292
6d4231b6f9fe switch statement prepare
kono
parents: 289
diff changeset
538 // gexpr_init();
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
539 if (dual_ops(op) && (car(caddr(e1))==CONST||(car(caddr(e1))==DCONST)))
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
540 b_expr(list3(rop_dual(op),caddr(e1),cadr(e1)),cond,l1,0);
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
541 else
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
542 b_expr(e1,cond,l1,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
543 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
544
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
545 /* bexpr for value used */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
546
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
547 extern void
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
548 bexpr(int e1, char cond, int l1)
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
549 {
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
550 int uses = use; use=1;
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
551 bexpr_u(e1, cond, l1);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
552 use = uses;
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
553 }
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
554
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
555 /* branch expression generator */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
556 /* if (cond?e1:!e1) goto l1 */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
557 /* 1 or 0 is return for code_bool */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
558
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
559 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
560 b_expr(int e1, char cond, int l1,int err)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
561 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
562 int e2,l2,t;
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
563 if (!control) return;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
564 l2 = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
565 e2=cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
566 switch(car(e1)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
567 case LNOT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
568 b_expr(e2,!cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
569 return;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
570 case GT: case GE: case LT: case LE:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
571 case EQ: case NEQ:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
572 rexpr(e1,l1,cond,INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
573 return;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
574 case UGT: case UGE: case ULT: case ULE:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
575 rexpr(e1,l1,cond,UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
576 return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
577 #if FLOAT_CODE
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
578 case DOP+GT:
194
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
579 case DOP+GE:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
580 case DOP+EQ:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
581 case DOP+NEQ:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
582 case FOP+GT:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
583 case FOP+GE:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
584 case FOP+EQ:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
585 case FOP+NEQ:
229
d793c84b3679 *** empty log message ***
kono
parents: 223
diff changeset
586 drexpr(cadr(e1),caddr(e1),l1,car(e1),cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
587 return;
194
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
588 case FOP+LT:
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
589 case FOP+LE:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
590 case DOP+LT:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
591 case DOP+LE:
232
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
592 drexpr(caddr(e1),cadr(e1),l1,rop_dual(car(e1)),cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
593 return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
594 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
595 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
596 case LOP+GT:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
597 case LOP+GE:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
598 case LOP+EQ:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
599 case LOP+NEQ:
210
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
600 case LOP+UGT:
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
601 case LOP+UGE:
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
602 lrexpr(cadr(e1),caddr(e1),l1,car(e1),cond);
210
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
603 return;
232
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
604 case LOP+LT:
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
605 case LOP+LE:
210
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
606 case LOP+ULT:
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
607 case LOP+ULE:
232
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
608 lrexpr(caddr(e1),cadr(e1),l1,rop_dual(car(e1)),cond);
210
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
609 return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
610 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
611 case LAND:
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
612 bexpr(e2,0,cond?(l2=fwdlabel()):l1);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
613 bexpr_u(caddr(e1),cond,l1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
614 if(cond) fwddef(l2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
615 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
616 case LOR:
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
617 bexpr(e2,1,cond?l1:(l2=fwdlabel()));
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
618 bexpr_u(caddr(e1),cond,l1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
619 if(!cond) fwddef(l2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
620 return;
167
0197ca125567 mips short
kono
parents: 166
diff changeset
621 case CRGVAR: case CURGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
622 code_cmp_crgvar(e1,USE_CREG,1,l1,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
623 return;
167
0197ca125567 mips short
kono
parents: 166
diff changeset
624 case SRGVAR: case SURGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
625 code_cmp_crgvar(e1,USE_CREG,size_of_short,l1,cond);
167
0197ca125567 mips short
kono
parents: 166
diff changeset
626 return;
0197ca125567 mips short
kono
parents: 166
diff changeset
627 case CRLVAR: case CURLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
628 code_cmp_crlvar(e2,USE_CREG,1,l1,cond);
167
0197ca125567 mips short
kono
parents: 166
diff changeset
629 return;
0197ca125567 mips short
kono
parents: 166
diff changeset
630 case SRLVAR: case SURLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
631 code_cmp_crlvar(e2,USE_CREG,size_of_short,l1,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
632 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
633 case RGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
634 code_cmp_rgvar(e1,USE_CREG,l1,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
635 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
636 case RLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
637 code_cmp_rlvar(e2,USE_CREG,l1,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
638 return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
639 #if FLOATC_DOE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
640 case DRLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
641 code_cmp_drlvar(e2,USE_CREG,1,l1,cond);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
642 return;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
643 case FRLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
644 code_cmp_drlvar(e2,USE_CREG,0,l1,cond);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
645 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
646 case DRGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
647 code_cmp_drgvar(e2,USE_CREG,1,l1,cond);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
648 return;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
649 case FRGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
650 code_cmp_drgvar(e2,USE_CREG,0,l1,cond);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
651 return;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
652 case FREGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
653 code_cmp_dregister(e2,0,l1,cond);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
654 return;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
655 case DREGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
656 code_cmp_dregister(e2,1,l1,cond);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
657 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
658 case DCONST:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
659 case FCONST:
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
660 if(control&&((dcadr(e2)!=0.0)^cond)) jmp(l1);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
661 return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
662 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
663 #if LONGLONG_DOE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
664 case LRLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
665 code_cmp_lrlvar(e2,1,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
666 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
667 case LRGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
668 code_cmp_lrgvar(e2,1,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
669 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
670 case LREGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
671 code_cmp_lregister(e2,1,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
672 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
673 case LCONST:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
674 if(control&&((lcadr(e2)!=0)^cond)) jmp(l1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
675 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
676 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
677 case REGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
678 code_cmp_register(e2,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
679 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
680 case CONST:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
681 if(control&&((cond&&e2)||(!cond&&!e2))) jmp(l1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
682 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
683 default:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
684 if(err) {
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
685 error(-1); return; /* recursive g_expr/b_expr */
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
686 }
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
687 t=g_expr(e1);
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
688 if (!use) return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
689 if (0) ;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
690 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
691 else if(t==FLOAT)
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
692 code_cmp_dregister(USE_CREG,0,l1,cond);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
693 else if(t==DOUBLE)
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
694 code_cmp_dregister(USE_CREG,1,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
695 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
696 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
697 else if(t==LONGLONG||t==ULONGLONG)
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
698 code_cmp_lregister(USE_CREG,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
699 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
700 else
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
701 code_cmp_register(USE_CREG,l1,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
702 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
703 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
704 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
705
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
706 extern int
126
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
707 is_code(NMTBL *fnptr)
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
708 {
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
709 int type = fnptr->ty;
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
710 return type==CODE|| (type>0 && car(type)==CODE);
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
711 }
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
712
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
713 extern int
126
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
714 is_function(NMTBL *fnptr)
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
715 {
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
716 int type = fnptr->ty;
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
717 return type==FUNCTION || (type>0 && car(type)==FUNCTION);
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
718 }
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
719
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
720 extern int
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
721 function_type(int e1,int *dots)
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
722 {
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
723 int ret_type,t;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
724 ret_type = cadr(e1);
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
725 if (ret_type==CHAR) ret_type=INT;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
726
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
727 /* check argments type is DOTS? */
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
728 t = caddr(e1);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
729 if (/* t==0 || */ t==DOTS) *dots = 1;
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
730 else {
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
731 *dots = 0;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
732 for(;t;t = cadr(t)) {
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
733 if (car(t)==DOTS) *dots = 1;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
734 }
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
735 }
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
736
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
737 return ret_type;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
738 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
739
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
740 static int
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
741 register_to_lvar(int e)
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
742 {
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
743 error(REG_ERR);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
744 return 0;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
745 #if 0
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
746 ÅÓÃæ¤Ç¥ì¥¸¥¹¥¿¤«¤éLVAR¤ËÊѹ¹¤·¤Æ¤â¡¢´Ö¤Ë¹ç¤ï¤Ê¤¤¡£
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
747
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
748 NMTBL *n = (NMTBL*)caddr(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
749 int reg = cadr(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
750 int tag = car(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
751 int lvar;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
752 int t;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
753 if (!n||n==&null_nptr) error(REG_ERR);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
754 if (tag==REGISTER) {
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
755 n->dsp = new_lvar(size_of_int);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
756 t = INT;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
757 } else if (tag==DREGISTER) {
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
758 n->dsp = new_lvar(size_of_double);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
759 t = DOUBLE;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
760 } else if (tag==FREGISTER) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
761 n->dsp = new_lvar(size_of_float);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
762 t = DOUBLE;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
763 } else if (tag==LREGISTER) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
764 n->dsp = new_lvar(size_of_longlong);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
765 t = LONGLONG;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
766 } else error(-1);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
767 n->sc = LVAR;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
768 lvar = list2(LVAR,n->dsp);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
769 g_expr_u(assign_expr0(list2(LVAR,n->dsp),list3(tag,reg,(int)n),t,t));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
770 if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
771 free_register(reg);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
772 return g_expr0(lvar);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
773 #endif
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
774 }
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
775
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
776 // parallel assignment of registers.
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
777 //
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
778 // target = list3(target_regnum,next,source_regnum);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
779
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
780 extern void
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
781 parallel_rassign(int assigns)
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
782 {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
783 int free,tmp,tmp_target,remains,t0,t2,src;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
784 tmp = 0;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
785 for(;;) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
786 remains = 0;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
787 // find free target
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
788 for(free=assigns;free;free=cadr(free)) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
789 if (!caddr(free)) continue; // already done
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
790 remains++;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
791 t0 = car(free); // target register
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
792 // check target is free
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
793 for(src=assigns;src;src=cadr(src)) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
794 if ((t2=caddr(src)) && t0==t2) break; // target is in source
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
795 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
796 if (src==0) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
797 break; // free is a free target
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
798 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
799 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
800 if (remains==0) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
801 if (tmp) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
802 code_rlvar(tmp,tmp_target);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
803 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
804 return;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
805 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
806 if (free) { // free target
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
807 if (t0!=caddr(free))
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
808 code_assign_register(t0,0,caddr(free));
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
809 } else { // no free target
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
810 for(free=assigns;free;free=cadr(free)) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
811 if (caddr(free)) break; // not yet done
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
812 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
813 if (!free) error(-1);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
814 tmp = new_lvar(size_of_int);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
815 tmp_target = car(free);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
816 code_assign_lvar(tmp,caddr(free),0);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
817 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
818 caddr(free)=0; // mark it done
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
819 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
820 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
821
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
822 /* goto arguments list */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
823 /* target list4(list2(tag,disp),cdr,ty,source_expr) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
824 /* source expr=listn(tag,...) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
825 /* source (after) list2(tag,disp) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
826 /* source list list3(e,cdr,sz) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
827
284
ec1a68133f6a MIPS f2u bug fix.
kono
parents: 280
diff changeset
828 #define DEBUG_PARALLEL_ASSIGN 0
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
829
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
830 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
831 overrap(int t,int sz,int source)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
832 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
833 int s,s0,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
834 int t0=cadr(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
835 int t1=t0+sz;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
836 for(;source;source=cadr(source)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
837 s=car(source); s0=cadr(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
838 if(car(s)==REGISTER && car(t)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
839 if(s0==t0) return s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
840 } else if (is_same_type(s,t)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
841 s1=s0+caddr(source);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
842 #if DEBUG_PARALLEL_ASSIGN>1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
843 printf("# ovedrrap source %d t0 %d t1 %d\n",car(car(t)),t0,t1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
844 printf("# ovedrrap target %d s0 %d s1 %d\n",car(car(source)),s0,s1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
845 printf("# ovedrrap equal = %d\n",((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
846 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
847 if((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)) return s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
848 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
849 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
850 return 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
851 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
852
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
853 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
854 remove_target(int *target,int t,int *use)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
855 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
856 int use0=*use;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
857 int reg;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
858 while(use0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
859 if (car(use0)==t) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
860 reg = car(caddr(use0));
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
861 if (reg==REGISTER||reg==FREGISTER||reg==DREGISTER)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
862 free_register(cadr(caddr(use0)));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
863 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
864 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
865 use0 = cadr(use0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
866 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
867 remove0(target,t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
868 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
869
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
870 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
871 save_target(int t,int s,int *target,int *use,int sz,int ty)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
872 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
873 int e1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
874 /*¿·¤·¤¤¥ì¥¸¥¹¥¿(or ¥¹¥¿¥Ã¥¯)¤ò¼èÆÀ¤¹¤ë*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
875 if (sz==size_of_int && (e1=get_register())!=-1) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
876 e1=list3(REGISTER,e1,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
877 *use=list3(t,*use,e1);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
878 g_expr_u(assign_expr0(e1,s,ty,ty));
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
879 *target = append4(*target,t,ty,e1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
880 #if FLOAT_CODE
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
881 } else if (sz==size_of_double && (e1=get_dregister(1))!=-1) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
882 e1=list3(DREGISTER,e1,0);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
883 *use=list3(t,*use,e1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
884 g_expr_u(assign_expr0(e1,s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
885 *target = append4(*target,t,ty,e1);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
886 } else if (sz==size_of_float && (e1=get_dregister(0))!=-1) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
887 e1=list3(FREGISTER,e1,0);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
888 *use=list3(t,*use,e1);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
889 g_expr_u(assign_expr0(e1,s,ty,ty));
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
890 *target = append4(*target,t,ty,e1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
891 #endif
205
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
892 #if LONGLONG_CODE
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
893 } else if (sz==size_of_longlong && (e1=get_lregister())!=-1) {
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
894 e1=list3(LREGISTER,e1,0);
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
895 *use=list3(t,*use,e1);
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
896 g_expr_u(assign_expr0(e1,s,ty,ty));
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
897 *target = append4(*target,t,ty,e1);
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
898 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
899 } else {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
900 g_expr_u(assign_expr0((e1=list2(LVAR,new_lvar(sz))),s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
901 *target = append4(*target,t,ty,e1);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
902 *use=list3(t,*use,e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
903 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
904 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
905
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
906 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
907 circular_dependency(int t,int s,int *target,int *source)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
908 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
909 int target0=*target;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
910 int t1,sz,ty,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
911 while(target0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
912 if (cadddr(target0)==s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
913 t1=car(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
914 s=cadddr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
915 sz=size(ty=caddr(target0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
916 if(t==t1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
917 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
918 printf("# circular dependency %d ty %d+%d sz %d\n",car(t1),ty,cadr(t1),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
919 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
920 return 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
921 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
922 if ((s1=overrap(t1,sz,*source))) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
923 /* another overrap start over */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
924 return circular_dependency(t,s1,target,source);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
925 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
926 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
927 target0=cadr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
928 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
929 return 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
930 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
931
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
932 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
933 parallel_assign(int *target,int *source,int *processing,int *use)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
934 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
935 int t,s,sz,ty,target0,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
936 while(*target) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
937 target0=*target;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
938 while(target0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
939 t=car(target0); s=cadddr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
940 sz=size(ty=caddr(target0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
941 if(car(t)==car(s) && cadr(t)==cadr(s)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
942 /*½ñ¤­¹þ¤ßÀ褬¼«Ê¬¼«¿È*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
943 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
944 printf("# remove same %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
945 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
946 remove_target(target,t,use);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
947 /* Ç˲õ¤µ¤ì¤Æ¤Ïº¤¤ë¤Î¤Ç¡¢source list¤«¤é¤Ï½ü¤«¤Ê¤¤ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
948 } else if (!(s1=overrap(t,sz,*source))) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
949 /* ½Å¤Ê¤Ã¤Æ¤Ê¤¤¤Î¤Ç°Â¿´¤·¤Æ½ñ¤­¹þ¤á¤ë */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
950 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
951 printf("# normal assign %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
952 #endif
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
953 g_expr_u(assign_expr0(t,s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
954 remove_target(target,t,use); remove0(source,s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
955 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
956 if(circular_dependency(t,s1,target,source)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
957 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
958 printf("# saving %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
959 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
960 remove_target(target,t,use); remove0(source,s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
961 save_target(t,s,target,use,sz,ty);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
962 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
963 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
964 target0=cadr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
965 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
966 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
967 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
968
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
969 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
970 remove0(int *parent,int e)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
971 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
972 int list;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
973 while ((list=*parent)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
974 if (car(list)==e) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
975 *parent= cadr(list); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
976 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
977 parent=&cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
978 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
979 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
980 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
981
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
982 /*
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
983 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
984 remove0_all(int *parent,int e)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
985 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
986 int list;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
987 while ((list=*parent)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
988 if (car(list)==e) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
989 *parent= cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
990 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
991 parent=&cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
992 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
993 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
994 }
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
995 */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
996
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
997 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
998 is_simple(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
999 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1000 return (
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1001 e1==CONST || e1==FNAME || e1==LVAR || e1==REGISTER ||e1==DREGISTER ||
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1002 e1==FREGISTER || e1==LREGISTER ||
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1003 e1==GVAR || e1==RGVAR || e1==RLVAR || e1==CRLVAR || e1==CRGVAR ||
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1004 e1==DRLVAR || e1==FRLVAR || e1==LRLVAR ||
165
kono
parents: 164
diff changeset
1005 e1==CURLVAR || e1==SURLVAR || e1==CURGVAR || e1==SURGVAR
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1006 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1007 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1008
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1009 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1010 is_same_type(int e1,int e2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1011 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1012 int ce1=car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1013 int ce2=car(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1014 return (
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1015 (ce1==LVAR && (ce2==RLVAR||ce2==CRLVAR||ce2==FRLVAR||ce2==DRLVAR))
165
kono
parents: 164
diff changeset
1016 || (ce1==LVAR && (ce2==SRLVAR||ce2==SURLVAR||ce2==CURLVAR))
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1017 || (ce2==LVAR && (ce1==RLVAR||ce1==CRLVAR||ce1==FRLVAR||ce1==DRLVAR))
165
kono
parents: 164
diff changeset
1018 || (ce2==LVAR && (ce1==SRLVAR||ce1==SURLVAR||ce1==CURLVAR))
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1019 || (ce2==LVAR && (ce1==LRLVAR))
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1020 || (ce1==GVAR && (ce2==RGVAR||ce2==CRGVAR||ce2==FRGVAR||ce2==DRGVAR))
165
kono
parents: 164
diff changeset
1021 || (ce1==GVAR && (ce2==SRGVAR||ce2==SURGVAR||ce2==CURGVAR))
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1022 || (ce2==GVAR && (ce1==RGVAR||ce1==CRGVAR||ce1==FRGVAR||ce1==DRGVAR))
165
kono
parents: 164
diff changeset
1023 || (ce2==GVAR && (ce1==SRGVAR||ce1==SURGVAR||ce1==CURGVAR))
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1024 || (ce2==GVAR && (ce1==LRGVAR))
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1025 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1026 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1027
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1028 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1029 is_memory(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1030 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1031 int ce1=car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1032 return (
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1033 ce1==LVAR ||ce1==RLVAR||ce1==CRLVAR || ce1==DRLVAR || ce1==LRLVAR ||
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1034 ce1==GVAR ||ce1==RGVAR||ce1==CRGVAR || ce1==DRGVAR || ce1==LRGVAR ||
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1035 ce1==FRLVAR || ce1==FRGVAR ||
165
kono
parents: 164
diff changeset
1036 ce1==CURGVAR ||ce1==SURGVAR||ce1==SRGVAR ||
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1037 ce1==REGISTER|| ce1==DREGISTER || ce1==FREGISTER ||
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1038 ce1==LREGISTER
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1039 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1040 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1041
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1042
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1043 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1044 jump(int e1, int env)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1045 {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1046 int e2,e3,e4,sz,arg_size,ty,regs,fregs;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1047 int t0,s0,r,reg;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1048 NMTBL *code0 = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1049 int target = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1050 int source = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1051 int processing = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1052 int use = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1053
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1054 /* ¤Þ¤º¡¢¥µ¥¤¥º¤ò·×»»¤·¤Ê¤¬¤é¡¢·è¤Þ¤Ã¤¿·Á¤ËÍ¡£ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1055
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1056 arg_size = 0; regs = 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1057 fregs = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1058 for (e3 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1059 e2 = car(e3); sz = size(ty=caddr(e3));
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1060 if (scalar(ty) && (r = get_input_register_var(regs,0,1))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1061 target=list4(r,target,ty,e2); regs++;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1062 } else if (ty==FLOAT && (r = get_input_dregister_var(fregs,0,1,0))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1063 target=list4(r, target,ty,e2); fregs++;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1064 } else if (ty==DOUBLE && (r = get_input_dregister_var(fregs,0,1,1))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1065 target=list4(r, target,ty,e2); fregs++;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1066 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1067 target=list4(list2(LVAR,0), target,ty,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1068 }
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1069 /* keep arg space for register variables */
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1070 arg_size += sz;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1071 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1072 printf("# target %d ty %d+%d sz %d\n",car(car(target)),ty,cadr(car(target)),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1073 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1074 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1075
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1076 /* disp ¤òÈô¤ÓÀè»÷¹ç¤ï¤»¤Æ½¤Àµ */
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1077 if (is_code(fnptr)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1078 if (-arg_size<disp) disp = -arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1079 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1080 if (disp_offset-arg_size<disp) disp = disp_offset-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1081 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1082
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1083 /* Ê£»¨¤Ê¼°¤òÁ°¤â¤Ã¤Æ·×»»¤·¤Æ¤ª¤¯ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1084 /* ɬÍפʤé¶É½êÊÑ¿ô¤òÍѤ¤¤ë¡£ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1085 /* ¶É½êÊÑ¿ô¤Ø¤Î¥ª¥Õ¥»¥Ã¥È¤ò³Ð¤¨¤Æ¤ª¤¯ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1086
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1087 for (e2 = target; e2; e2 = cadr(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1088 t0=car(e2); s0=cadddr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1089 sz=size(ty=caddr(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1090 if(car(t0)==LVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1091 /* ¤³¤³¤Ç¡¢½ñ¹þÀ襢¥É¥ì¥¹¤ò·è¤á¤ë */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1092 cadr(t0)=-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1093 }
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1094 arg_size-=sz;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1095 if (!is_simple(car(s0))) {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
1096 g_expr_u(assign_expr0((e4=list2(LVAR,new_lvar(sz))),s0,ty,ty));
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1097 use=list3(ty,use,e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1098 cadddr(e2)=e4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1099 s0=e4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1100 } else if (is_same_type(t0,s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1101 if(cadr(t0)==cadr(s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1102 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1103 printf("# remove same memory %d ty %d+%d sz %d\n",car(t0),ty,cadr(t0),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1104 #endif
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1105 /* we should check size also (but currently useless) */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1106 remove0(&target,t0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1107 /* still we have source to avoid overwrite */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1108 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1109 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1110 if(is_memory(s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1111 source=list3(s0,source,sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1112 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1113 printf("# source %d ty %d+%d sz %d\n",car(car(source)),ty,cadr(car(source)),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1114 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1115 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1116 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1117
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1118 /* compute jump address */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1119 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1120 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1121 code0=(NMTBL *)cadr(e2);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1122 if (!is_code(code0)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1123 error(TYERR); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1124 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1125 } else { /* indirect */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1126 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1127 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1128 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1129 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1130 g_expr(env);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1131 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1132 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1133
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1134 /* ÊÂÎóÂåÆþ¤ò¼Â¹Ô */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1135 parallel_assign(&target,&source,&processing,&use);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1136 while (use) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1137 reg = car(caddr(use));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1138 if (reg==REGISTER||reg==FREGISTER||reg==DREGISTER||reg==LREGISTER)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1139 free_register(cadr(caddr(use)));
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1140 else if (car(caddr(use))==LVAR)
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1141 free_lvar(cadr(caddr(use)));
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1142 use=cadr(use);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1143 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1144 if(target) error(-1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1145
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1146 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1147 /* change the frame pointer */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1148 e3 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1149 code_frame_pointer(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1150 emit_pop_free(e3);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1151 } else if (is_function(fnptr)) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1152 if (car(e2) != FNAME) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1153 e2 = emit_pop(0);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1154 code_fix_frame_pointer(disp_offset);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1155 code_indirect_jmp(e2);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1156 emit_pop_free(e2);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1157 return;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1158 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1159 code_fix_frame_pointer(disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1160 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1161
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1162 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1163 code_jmp(code0->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1164 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1165 e2 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1166 code_indirect_jmp(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1167 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1168 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1169 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1170
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1171 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1172 machinop(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1173 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1174 int e2,e3,op;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1175
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1176 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1177 op = car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1178 e3 = caddr(e1);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1179 if (code_const_op_p(op,e3)) {
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1180 g_expr(e2);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1181 oprtc(op,USE_CREG,e3);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1182 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1183 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1184 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1185 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1186 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1187 tosop(op,USE_CREG,(e2=pop_register()));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1188 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1189 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1190 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1191
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1192 #if FLOAT_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1193 static void
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1194 dmachinop(int e1,int d)
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1195 {
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1196 int e2,e3,op;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1197
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1198 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1199 op = car(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1200 e3 = caddr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1201 g_expr(e3);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1202 emit_dpush(d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1203 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1204 dtosop(car(e1),USE_CREG,(e2=emit_dpop(d)));
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1205 emit_dpop_free(e2,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1206 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1207 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1208 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1209
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1210 #if LONGLONG_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1211 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1212 lmachinop(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1213 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1214 int e2,e3,op;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1215
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1216 e2 = cadr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1217 op = car(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1218 e3 = caddr(e1);
213
kono
parents: 212
diff changeset
1219 if (code_lconst_op_p(op,e3)) {
kono
parents: 212
diff changeset
1220 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1221 loprtc(op,USE_CREG,e3);
213
kono
parents: 212
diff changeset
1222 return;
kono
parents: 212
diff changeset
1223 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1224 g_expr(e3);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1225 emit_lpush();
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1226 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1227 ltosop(car(e1),USE_CREG,(e2=emit_lpop()));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1228 emit_lpop_free(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1229 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1230 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1231 #endif
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1232
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1233 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1234 sassign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1235 {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1236 int e2,e3,e4,sz,xreg,det,offset;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1237
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1238 /* structure assignment */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1239 e2 = cadr(e1); /* pointer variable to the struct */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1240 e3 = cadr(e2); /* offset of the variable (distination) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1241 e4 = caddr(e1); /* right value (source) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1242 sz = cadddr(e1); /* size of struct or union */
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1243 if (is_same_type(e2,e4)&&cadr(e2)==cadr(e4)) {
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1244 if (use) g_expr(e4);
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1245 return;
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1246 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1247 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1248 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1249 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1250 xreg = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1251 /* °ìÈÌŪ¤Ë¤Ï¥³¥Ô¡¼¤Î¥ª¡¼¥Ð¥é¥Ã¥×¤Î¾õ¶·¤Ï¼Â¹Ô»þ¤Ë¤·¤«¤ï¤«¤é¤Ê¤¤ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1252 /* ¤·¤«¤·¡¢¤ï¤«¤ë¾ì¹ç¤â¤¢¤ë */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1253 if (car(e4)==RSTRUCT) e4=cadr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1254 if (is_same_type(e2,e4)) {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1255 if(cadr(e2)<cadr(e4)) { offset=sz; sz=-sz;}
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1256 det=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1257 } else {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1258 det = 0; offset=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1259 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1260 emit_copy(xreg,USE_CREG,sz,offset,1,det);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1261 emit_pop_free(xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1262 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1263 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1264
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1265 static void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1266 assign_opt(int e5,int e2,int e4,int byte)
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1267 {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1268 int reg;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1269 /* e2=e4 */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1270 if (e5==REGISTER) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1271 reg = cadr(e4);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1272 switch(car(e2)) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1273 case GVAR: code_assign_gvar(e2,reg,byte); return;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1274 case LVAR: code_assign_lvar(cadr(e2),reg,byte); return;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1275 case REGISTER: code_assign_register(cadr(e2),byte,reg); return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1276 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1277 g_expr(e2);
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
1278 code_assign(USE_CREG,byte,reg);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1279 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1280 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1281 /* e2 is register now */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1282 if (car(e2)!=REGISTER) error(-1);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1283 reg = cadr(e2);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1284 switch(e5) {
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1285 case CRGVAR:
165
kono
parents: 164
diff changeset
1286 case CURGVAR: code_crgvar(e4,reg,e5==CRGVAR,1); return;
kono
parents: 164
diff changeset
1287 case SRGVAR:
kono
parents: 164
diff changeset
1288 case SURGVAR: code_crgvar(e4,reg,e5==SRGVAR,size_of_short); return;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1289 case RGVAR: code_rgvar(e4,reg); return;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1290 case CRLVAR:
165
kono
parents: 164
diff changeset
1291 case CURLVAR: code_crlvar(cadr(e4),reg,e5==CRLVAR,1); return;
kono
parents: 164
diff changeset
1292 case SRLVAR:
kono
parents: 164
diff changeset
1293 case SURLVAR: code_crlvar(cadr(e4),reg,e5==SRLVAR,size_of_short); return;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1294 case RLVAR: code_rlvar(cadr(e4),reg); return;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1295 case GVAR: code_gvar(e4,reg); return;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1296 case LVAR: code_lvar(cadr(e4),reg); return;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1297 case CONST: code_const(cadr(e4),reg); return;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1298 case ADDRESS:
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1299 if (car(cadr(e4))==STRING) code_string(cadr(e4),reg);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1300 else code_gvar(cadr(e4),reg);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1301 return;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1302 case FNAME: code_fname((NMTBL*)cadr(e4),reg); return;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1303 case STRING: code_string(e4,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1304 default: error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1305 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1306 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1307
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1308 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1309 assign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1310 {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1311 int e2,e4,byte,e5;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1312
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
1313 byte=(car(e1) == CASS)?1:(car(e1) == SASS)?size_of_short:0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1314 /* e2=e4 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1315 e2 = cadr(e1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1316 e4 = caddr(e1);e5=car(e4);
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1317 if (is_same_type(e2,e4)&&cadr(e2)==cadr(e4)) {
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1318 if (use) g_expr(e4);
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1319 return;
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1320 }
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1321 if (!use && (
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1322 (e5==REGISTER) ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1323 (car(e2)==REGISTER&&(
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1324 e5== CRGVAR || e5== CRLVAR || e5== RGVAR || e5== RLVAR ||
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1325 e5== CURGVAR || e5== CURLVAR ||
165
kono
parents: 164
diff changeset
1326 e5== SURGVAR || e5== SURLVAR ||
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1327 e5== GVAR || e5== LVAR ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1328 e5== CONST || e5== FNAME || e5== STRING ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1329 (e5==ADDRESS&&car(cadr(e4))==STRING) ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1330 (e5==ADDRESS&&car(cadr(e4))==GVAR) )))) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1331 assign_opt(e5,e2,e4,byte);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1332 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1333 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1334 switch(car(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1335 case GVAR: /* i=3 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1336 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1337 code_assign_gvar(e2,USE_CREG,byte);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1338 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1339 case LVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1340 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1341 code_assign_lvar(cadr(e2),USE_CREG,byte);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1342 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1343 case REGISTER:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1344 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1345 code_assign_register(cadr(e2),byte,USE_CREG);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1346 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1347 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1348 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1349 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1350 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1351 e2 = emit_pop(0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1352 code_assign(e2,byte,USE_CREG);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1353 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1354 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1355 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1356
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1357 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1358
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1359 static void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1360 dassign_opt(int e5,int e2,int e4,int d)
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1361 {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1362 int reg;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1363 /* e2=e4 */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1364 if (e5==DREGISTER||e5==FREGISTER) {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1365 reg = cadr(e4);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1366 switch(car(e2)) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1367 case GVAR: /* i=3 */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1368 code_dassign_gvar(e2,reg,d);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1369 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1370 case LVAR:
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1371 code_dassign_lvar(cadr(e2),reg,d);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1372 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1373 case DREGISTER:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1374 case FREGISTER:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1375 if (reg!=cadr(e2))
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1376 code_dassign_dregister(cadr(e2),d,reg);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1377 return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1378 default:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1379 error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1380 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1381 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1382 /* e2 is register now */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1383 if (car(e2)!=DREGISTER && car(e2)!=FREGISTER) error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1384 reg = cadr(e2);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1385 switch(e5) {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1386 case FRGVAR:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1387 case DRGVAR: code_drgvar(e4,d,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1388 case FRLVAR:
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1389 case DRLVAR: code_drlvar(cadr(e4),d,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1390 case FCONST:
264
7de200d88747 MIPS first binary run (inomplete)
kono
parents: 258
diff changeset
1391 case DCONST: code_dconst(e4,reg,d); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1392 default:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1393 error(-1);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1394 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1395 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1396
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1397 static void
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1398 dassign(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1399 {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1400 int e2,e3,e4,d,e5;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1401
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1402 /* e2=e4 */
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1403 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1404 e3 = cadr(e2);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1405 e4 = caddr(e1); e5=car(e4);
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1406 if (is_same_type(e2,e4)&&cadr(e2)==cadr(e4)) {
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1407 if (use) g_expr(e4);
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1408 return;
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1409 }
249
8313c965c0e2 *** empty log message ***
kono
parents: 246
diff changeset
1410 if (car(e1)==DASS) d=1;
8313c965c0e2 *** empty log message ***
kono
parents: 246
diff changeset
1411 else if (car(e1)==FASS) d=0;
8313c965c0e2 *** empty log message ***
kono
parents: 246
diff changeset
1412 else error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1413 if (!use && (
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1414 (e5==DREGISTER) || (e5==FREGISTER) ||
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1415 (car(e2)==DREGISTER&&(e5==DRGVAR||e5==DRLVAR||e5==DCONST))||
249
8313c965c0e2 *** empty log message ***
kono
parents: 246
diff changeset
1416 (car(e2)==FREGISTER&&(e5==FRGVAR||e5==FRLVAR||e5==FCONST))
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1417 )) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1418 dassign_opt(e5,e2,e4,d);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1419 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1420 }
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1421 switch(car(e2)) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1422 case GVAR:
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1423 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1424 code_dassign_gvar(e2,USE_CREG,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1425 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1426 case LVAR:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1427 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1428 code_dassign_lvar(cadr(e2),USE_CREG,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1429 return;
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1430 case DREGISTER:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1431 case FREGISTER:
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1432 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1433 code_dassign_dregister(cadr(e2),d,USE_CREG);
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1434 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1435 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1436 g_expr(e2);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1437 emit_push();
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1438 g_expr(e4);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1439 e2 = emit_pop(0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1440 code_dassign(e2,USE_CREG,d);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1441 emit_pop_free(e2);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1442 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1443 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1444
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1445 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1446
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1447 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1448
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1449 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1450 lassign_opt(int e5,int e2,int e4)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1451 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1452 int reg;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1453 /* e2=e4 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1454 if (e5==LREGISTER) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1455 reg = cadr(e4);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1456 switch(car(e2)) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1457 case GVAR: /* i=3 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1458 code_lassign_gvar(e2,reg);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1459 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1460 case LVAR:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1461 code_lassign_lvar(cadr(e2),reg);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1462 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1463 case LREGISTER:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1464 if (reg!=cadr(e2))
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1465 code_lassign_lregister(cadr(e2),reg);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1466 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1467 default:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1468 error(-1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1469 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1470 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1471 /* e2 is register now */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1472 if (car(e2)!=LREGISTER) error(-1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1473 reg = cadr(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1474 switch(e5) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1475 case LRGVAR: code_lrgvar(e4,reg); return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1476 case LRLVAR: code_lrlvar(cadr(e4),reg); return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1477 case LCONST: code_lconst(e4,reg); return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1478 default:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1479 error(-1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1480 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1481 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1482
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1483 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1484 lassign(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1485 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1486 int e2,e3,e4,e5;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1487
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1488 /* e2=e4 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1489 e2 = cadr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1490 e3 = cadr(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1491 e4 = caddr(e1); e5=car(e4);
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1492 if (is_same_type(e2,e4)&&cadr(e2)==cadr(e4)) {
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1493 if (use) g_expr(e4);
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1494 return;
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1495 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1496 if (!use && (
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1497 (e5==LREGISTER) ||
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1498 (car(e2)==LREGISTER&&(e5==LRGVAR||e5==LRLVAR||e5==LCONST))
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1499 )) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1500 lassign_opt(e5,e2,e4);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1501 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1502 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1503 switch(car(e2)) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1504 case GVAR:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1505 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1506 code_lassign_gvar(e2,USE_CREG);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1507 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1508 case LVAR:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1509 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1510 code_lassign_lvar(cadr(e2),USE_CREG);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1511 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1512 case LREGISTER:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1513 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1514 code_lassign_lregister(cadr(e2),USE_CREG);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1515 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1516 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1517 g_expr(e2);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1518 emit_push();
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1519 g_expr(e4);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1520 e2 = emit_pop(0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1521 code_lassign(e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1522 emit_pop_free(e2);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1523 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1524 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1525
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1526 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1527
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1528 /* numerical type conversion */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1529
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1530 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1531 double_value(int e2,int type)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1532 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1533 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1534 if (car(e2)==CONST) return dlist2(DCONST,(double)cadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1535 if (car(e2)==FCONST) return dlist2(DCONST,dcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1536 if(type==DOUBLE) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1537 if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2D);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1538 if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2D);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1539 if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2D);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1540 if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2D);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1541 if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2D);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1542 error(TYERR); return dlist2(DCONST,1.0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1543 #else
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1544 error(TYERR); return list2(CONST,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1545 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1546 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1547
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1548 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1549 float_value(int e2,int type)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1550 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1551 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1552 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1553 if (car(e2)==LCONST) return dlist2(FCONST,(double)lcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1554 if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2F);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1555 if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2F);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1556 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1557 if (car(e2)==CONST) return dlist2(FCONST,(double)cadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1558 if (car(e2)==DCONST) return dlist2(FCONST,dcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1559 if(type==FLOAT) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1560 if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2F);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1561 if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2F);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1562 if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2F);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1563 error(TYERR); return dlist2(DCONST,1.0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1564 #else
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1565 error(TYERR); return list2(CONST,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1566 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1567 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1568
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1569 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1570 longlong_value(int e2,int type)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1571 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1572 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1573 if (car(e2)==CONST) return llist2(LCONST,(long long)cadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1574 if (car(e2)==LCONST) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1575 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1576 if (car(e2)==DCONST||car(e2)==FCONST)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1577 return llist2(LCONST,(long long)dcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1578 if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2LL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1579 if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2LL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1580 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1581 if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2LL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1582 if(type==LONGLONG) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1583 if(type==ULONGLONG) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1584 if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2LL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1585 error(TYERR); return llist2(LCONST,0LL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1586 #else
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1587 return int_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1588 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1589 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1590
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1591 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1592 ulonglong_value(int e2,int type)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1593 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1594 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1595 if (car(e2)==CONST) return llist2(LCONST,(unsigned long long)cadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1596 if (car(e2)==LCONST) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1597 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1598 if (car(e2)==DCONST||car(e2)==FCONST)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1599 return llist2(LCONST,(unsigned long long)dcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1600 if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2ULL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1601 if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2ULL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1602 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1603 if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2ULL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1604 if(type==LONGLONG) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1605 if(type==ULONGLONG) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1606 if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2ULL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1607 error(TYERR); return llist2(LCONST,0LL);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1608 #else
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1609 unsigned_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1610 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1611 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1612
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1613 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1614 int_value(int e2,int type)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1615 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1616 if(scalar(type)) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1617 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1618 if (car(e2)==DCONST||car(e2)==FCONST) return list2(CONST,(int)dcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1619 if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2I);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1620 if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2I);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1621 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1622 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1623 if (car(e2)==LCONST) return list2(CONST,(int)lcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1624 if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2I);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1625 if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2I);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1626 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1627 if(car(type)==ARRAY) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1628 error(TYERR); return list2(CONST,1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1629 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1630
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1631 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1632 unsigned_value(int e2,int type)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1633 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1634 if(scalar(type)) return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1635 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1636 // if (car(e2)==DCONST||car(e2)==FCONST) return list2(CONST,(unsigned)dcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1637 if (car(e2)==DCONST||car(e2)==FCONST) return list2(CONST,(int)dcadr(e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1638 if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2U);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1639 if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2U);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1640 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1641 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1642 if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2U);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1643 if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2U);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1644 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1645 error(TYERR); return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1646 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1647
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1648 /* assign statement */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1649
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1650 /* keep type */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1651
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1652 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1653 assign_expr0(int e1,int e2,int t,int type0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1654 int stype;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1655 stype=type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1656 type = type0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1657 e2 = rvalue(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1658 e1=assign_expr(e1,e2,t,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1659 type=stype;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1660 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1661 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1662
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1663
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1664
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1665 /* with conversion (will destroy type global variable) */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1666
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1667 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1668 assign_expr(int e1,int e2,int t,int type) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1669 if(t==VOID)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1670 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1671 if(t==CHAR||t==UCHAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1672 e2=(t==UCHAR)?unsigned_value(e2,type):int_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1673 if (!integral(type)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1674 type= INT;return(list3(CASS,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1675 } else if(t==SHORT||t==USHORT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1676 e2=(t==USHORT)?unsigned_value(e2,type):int_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1677 if (!integral(type)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1678 type= t;return(list3(SASS,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1679 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1680 } else if(t==DOUBLE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1681 e2=double_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1682 type= t;return(list3(DASS,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1683 } else if(t==FLOAT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1684 e2=float_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1685 type= t;return(list3(FASS,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1686 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1687 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1688 } else if(t==LONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1689 e2=longlong_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1690 type= t;return(list3(LASS,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1691 } else if(t==ULONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1692 e2=ulonglong_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1693 type= t;return(list3(LASS,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1694 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1695 } else if(scalar(t)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1696 e2=(t==UNSIGNED)?unsigned_value(e2,type):int_value(e2,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1697 type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1698 return(list3(ASS,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1699 } else if (car(t)==BIT_FIELD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1700 e2 = correct_type(e2,cadr(t));
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1701 return(list4(BASS,e1,e2,list2(BASS,t)));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1702 } else if((car(t)==STRUCT||car(t)==UNION)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1703 if (size(t)!=size(type)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1704 type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1705 if(car(e2)==RSTRUCT && car(cadr(e2))==FUNCTION) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1706 replace_return_struct(cadr(e2),e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1707 return cadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1708 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1709 return (list4(STASS,e1,e2,size(t)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1710 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1711 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1712 error(TYERR); return list3(ASS,e1,e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1713 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1714 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1715
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1716 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1717 cond(int t,int e1,int e2,int e3)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1718 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1719 if(car(e1)==CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1720 if(cadr(e1)) {type=t;return e2;} else return e3;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1721 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1722 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1723 if(type==DOUBLE||t==DOUBLE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1724 e2=double_value(e2,t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1725 e3=double_value(e3,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1726 t=type=DOUBLE;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1727 return(list4(DCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1728 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1729 if(type==FLOAT||t==FLOAT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1730 e2=float_value(e2,t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1731 e3=float_value(e3,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1732 t=type=FLOAT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1733 return(list4(FCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1734 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1735 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1736 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1737 if(type==LONGLONG||t==LONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1738 e2=longlong_value(e2,t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1739 e3=longlong_value(e3,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1740 t=type=LONGLONG;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1741 return(list4(LCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1742 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1743 if(type==ULONGLONG||t==ULONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1744 e2=ulonglong_value(e2,t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1745 e3=ulonglong_value(e3,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1746 t=type=ULONGLONG;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1747 return(list4(LCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1748 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1749 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1750 if(type==INT||(t!=INT&&type==UNSIGNED))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1751 type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1752 /* if (t!=type) error(TYERR); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1753 return(list4(COND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1754 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1755
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1756 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1757 assop(int e1,int e2,int op,int t,int no_float)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1758 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1759 if(!(integral(type)||type==FLOAT||type==DOUBLE||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1760 type==LONGLONG||type==ULONGLONG
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1761 )) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1762 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1763 if (t==FLOAT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1764 if (no_float) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1765 e2=float_value(e2,type); type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1766 return(list4(FASSOP,e1,e2,op+FOP));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1767 } else if (t==DOUBLE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1768 if (no_float) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1769 e2=double_value(e2,type); type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1770 return(list4(DASSOP,e1,e2,op+DOP));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1771 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1772 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1773 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1774 if (t==LONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1775 e2=longlong_value(e2,type); type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1776 return(list4(LASSOP,e1,e2,op+LOP));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1777 } else if (t==ULONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1778 e2=ulonglong_value(e2,type); type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1779 return(list4(LASSOP,e1,e2,op+LOP+((op==MUL+AS||op==DIV+AS)?US:0)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1780 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1781 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1782 if((t==UNSIGNED||t==UCHAR||t==USHORT||type==UNSIGNED)&&
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1783 (op==MUL||op==DIV||op==MOD))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1784 op=op+US;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1785 if((t==UNSIGNED||t==UCHAR||t==USHORT)&&(op==RSHIFT||op==LSHIFT))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1786 op=op+US;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1787 if(t==CHAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1788 type= INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1789 return(list4(CASSOP,e1,e2,op));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1790 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1791 if(t==UCHAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1792 type= UNSIGNED;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1793 return(list4(CUASSOP,e1,e2,op));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1794 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1795 if(t==SHORT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1796 type= INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1797 return(list4(SASSOP,e1,e2,op));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1798 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1799 if(t==USHORT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1800 type= UNSIGNED;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1801 return(list4(SUASSOP,e1,e2,op));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1802 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1803 if (t>0 && car(t)==BIT_FIELD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1804 e2 = correct_type(e2,cadr(t));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1805 return(list4(BASSOP,e1,e2,list2(op,t)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1806 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1807 type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1808 if(integral(t)) return(list4(ASSOP,e1,e2,op));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1809 /* pointer += ... */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1810 if((op!=ADD&&op!=SUB)||car(t)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1811 e2=binop(MUL,e2,list2(CONST,size(cadr(t))),INT,UNSIGNED);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1812 type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1813
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1814 return list4(ASSOP,e1,e2,op);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1815 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1816
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1817
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1818
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1819 static void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1820 iassop(int e1)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1821 {
165
kono
parents: 164
diff changeset
1822 int e2,e3,byte,op,sign,size;
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1823 int n,t;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1824
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1825 /* e2 op= e3 */
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1826 if (car(e1) == CUASSOP) {
165
kono
parents: 164
diff changeset
1827 byte = 1; sign = 0; size = 1;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1828 } else if (car(e1) == CASSOP) {
165
kono
parents: 164
diff changeset
1829 byte = 1; sign = 1; size = 1;
kono
parents: 164
diff changeset
1830 } else if (car(e1) == SUASSOP) {
kono
parents: 164
diff changeset
1831 byte = size_of_short; sign = 0; size = size_of_short;
kono
parents: 164
diff changeset
1832 } else if (car(e1) == SASSOP) {
kono
parents: 164
diff changeset
1833 byte = size_of_short; sign = 1; size = size_of_short;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1834 } else {
165
kono
parents: 164
diff changeset
1835 byte = 0; sign = 1; size = size_of_int;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1836 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1837 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1838 if (car(e2)==INDIRECT) e2=cadr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1839 e3 = caddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1840 op = cadddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1841
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1842 if (car(e2)==REGISTER) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1843 if (code_const_op_p(op,e3)) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1844 oprtc(op,cadr(e2),e3);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1845 } else {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1846 g_expr(e3);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1847 code_register_assop(cadr(e2),USE_CREG,op,byte);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1848 }
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1849 if (use) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1850 code_register(cadr(e2),USE_CREG);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1851 }
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1852 return;
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1853 }
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1854 if (car(e3)==CONST) {
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1855 /* e2 = e2 op e3; */
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1856 t = sign?INT:UNSIGNED;
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1857 // oprtc expected
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1858 if (car(e2)==LVAR||car(e2)==GVAR) {
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1859 g_expr(assign_expr0(e2,list3(op,rvalue_t(e2,t),e3),t,t));
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1860 return;
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1861 }
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1862 /* new = &e2 */
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1863 /* *new = *new op e3 */
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1864 n = list2(LVAR,new_lvar(size_of_int));
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1865 g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT));
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1866 g_expr(assign_expr0(list2(INDIRECT,n),list3(op,n,e3),t,t));
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1867 free_lvar(cadr(n));
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1868 return;
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
1869 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1870 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1871 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1872 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1873 code_assop(op,USE_CREG,byte,sign);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1874 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1875 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1876
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1877 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1878
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1879 static void
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1880 dassop(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1881 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1882 int e2,e3,op,d;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1883
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1884 /* e2 op= e3 */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1885 d = (car(e1) == DASSOP);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1886 e2 = cadr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1887 if (car(e2)==INDIRECT) e2=cadr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1888 e3 = caddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1889 op = cadddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1890
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1891 g_expr(e3);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1892 if (car(e2)==DREGISTER||car(e2)==FREGISTER) {
273
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
1893 emit_dpush(d);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1894 code_register_dassop(cadr(e2),op,d);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
1895 if (use)
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
1896 code_dregister(cadr(e2),USE_CREG,d);
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
1897 return;
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1898 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1899 emit_dpush(d);
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1900 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1901 code_dassop(op,USE_CREG,d);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1902 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1903 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1904
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1905 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1906
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1907 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1908
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1909 static int
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1910 long_sign(int op)
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1911 {
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1912 return (op==LUDIV||op==LUMOD||op==LULSHIFT||op==LURSHIFT)?ULONGLONG:LONGLONG;
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1913 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1914
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1915 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1916 lassop(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1917 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1918 int e2,e3,op;
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1919 int n,t;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1920
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1921 /* e2 op= e3 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1922 e2 = cadr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1923 if (car(e2)==INDIRECT) e2=cadr(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1924 e3 = caddr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1925 op = cadddr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1926
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1927 if (car(e2)==LREGISTER) {
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1928 if (code_lconst_op_p(op,e3)) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1929 loprtc(op,cadr(e2),e3);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1930 if (use) {
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1931 code_lregister(cadr(e2),USE_CREG);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1932 }
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1933 return;
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1934 }
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1935 if (code_lassop_p) {
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1936 g_expr(e3);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1937 emit_lpush();
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1938 code_register_lassop(cadr(e2),op);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1939 if (use) {
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1940 code_lregister(cadr(e2),USE_CREG);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1941 }
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1942 return;
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1943 }
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
1944 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1945 if (!code_lassop_p||car(e3)==LCONST) {
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1946 /* e2 = e2 op e3; */
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1947 t = long_sign(op);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1948 if (car(e2)==LREGISTER||car(e2)==LVAR||car(e2)==GVAR) {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1949 g_expr(assign_expr0(e2,list3(op,rvalue_t(e2,t),e3),t,t));
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1950 return;
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1951 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1952 /* new = &e2 */
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1953 /* *new = *new op e3 */
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1954 n = list2(LVAR,new_lvar(size_of_int));
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1955 g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT));
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1956 g_expr(assign_expr0(list2(INDIRECT,n),list3(op,n,e3),t,t));
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1957 free_lvar(cadr(n));
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1958 return;
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1959 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1960
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1961 g_expr(e3);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1962 if (car(e2)==LREGISTER) {
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1963 emit_lpush();
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1964 code_register_lassop(cadr(e2),op);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1965 if (use)
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1966 code_lregister(cadr(e2),USE_CREG);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1967 return;
179e22f166ef register assop fix
kono
parents: 285
diff changeset
1968 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1969 emit_lpush();
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
1970 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1971 code_lassop(op,USE_CREG);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1972 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1973 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1974
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1975 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1976
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1977 extern void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1978 cmpdimm(int e, int csreg,int label,int cond)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1979 {
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1980 code_cmpdimm(e, csreg,label,cond);
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1981 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1982
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1983 extern int
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1984 csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1985 {
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1986 return code_csvalue();
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1987 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1988
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1989
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1990 extern int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1991 fwdlabel(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1992 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1993 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1994 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1995
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1996 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1997 fwddef(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1998 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1999 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2000 if (!chk)
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
2001 code_label(l);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2002 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2003
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2004 extern int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2005 backdef(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2006 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2007 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2008 if (!chk)
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
2009 code_label(labelno);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2010 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2011 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2012
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2013 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2014 def_label(int cslabel, int dlabel)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2015 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2016 int fl;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2017
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2018 fl = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2019 if (control) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2020 jmp(fl=fwdlabel());
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2021 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2022 fwddef(cslabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2023 if (dlabel)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2024 jmp(dlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2025 if (fl) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2026 fwddef(fl);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2027 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2028 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2029
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2030 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2031 ret(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2032 {
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2033 code_set_return_register(1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2034 jmp(retlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2035 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2036
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2037 extern void
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2038 opening(char *filename)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2039 {
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2040 emit_init();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2041 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2042 code_opening(filename);
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2043 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2044
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2045 extern void
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2046 closing()
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2047 {
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2048 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2049 code_closing();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2050 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2051
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2052 static int
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2053 contains_in_list(int e,int type)
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2054 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2055 while(e) {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2056 if(contains(car(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2057 e = cadr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2058 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2059 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2060 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2061
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2062 static int
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2063 contains(int e,int type)
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2064 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2065 while(e) {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2066 if (car(e)==type) return 1;
256
d80e6387c539 powerpc function call complex arugment pre computation.
kono
parents: 255
diff changeset
2067 if (!car(e)) return 0;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2068 if (LIST_ARGS(car(e))){
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2069 /* list arguments */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2070 return contains_in_list(caddr(e),type);
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2071 } else if (UNARY_ARGS(car(e))) {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2072 /* unary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2073 e = cadr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2074 continue;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2075 } else if (BINARY_ARGS(car(e))) {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2076 /* biary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2077 if (contains(cadr(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2078 e = caddr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2079 continue;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2080 } else if (TARNARY_ARGS(car(e))) {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2081 /* tarary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2082 if (contains(cadr(e), type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2083 if (contains(caddr(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2084 e = cadddr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2085 continue;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2086 } else if (NULLARY_ARGS(car(e))) {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2087 /* nullary operators */
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2088 return 0;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2089 } else {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2090 // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2091 error(-1);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2092 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2093 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2094 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2095 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2096 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2097
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2098 static int
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2099 contains_in_list_p(int e,int (*p)(int))
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2100 {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2101 while(e) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2102 if(contains_p(car(e),p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2103 e = cadr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2104 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2105 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2106 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2107
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2108 extern int
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2109 contains_p(int e,int (*p)(int))
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2110 {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2111 while(e) {
256
d80e6387c539 powerpc function call complex arugment pre computation.
kono
parents: 255
diff changeset
2112 if (!car(e)) return 0;
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2113 if (p(car(e))) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2114 if (LIST_ARGS(car(e))){
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2115 /* list arguments */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2116 return contains_in_list_p(caddr(e),p);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2117 } else if (UNARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2118 /* unary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2119 e = cadr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2120 continue;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2121 } else if (BINARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2122 /* biary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2123 if (contains_p(cadr(e),p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2124 e = caddr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2125 continue;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2126 } else if (TARNARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2127 /* tarary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2128 if (contains_p(cadr(e), p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2129 if (contains_p(caddr(e),p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2130 e = cadddr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2131 continue;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2132 } else if (NULLARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2133 /* nullary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2134 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2135 } else {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2136 // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2137 error(-1);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2138 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2139 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2140 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2141 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2142 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2143
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2144 #if ASM_CODE
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2145
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2146
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2147 /*
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2148 __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (a
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2149 ddr));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2150 asm string : output constraint parameter : input constraint parameter : opt
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2151
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2152 1: asm string %1,%2 will be replaced by register or value
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2153 2: constraint gcc constraint sting
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2154 prefix
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2155 = overwrite by this asm for output
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2156 & overwrite by this asm and can't be used as input register
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2157 ignored in this compiler
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2158 constraints
326
e5d40f8c4cce bit-field continue.
kono
parents: 320
diff changeset
2159 m value expression is modified (no corresponding register)
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2160 information for compiler
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2161 r register for input or output
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2162 input register, output register can be shared
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2163 0-9 same operands as outout register in input constraints
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2164 3: opt "cc", "memory"
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2165 ignored in this compiler
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2166 */
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2167
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2168 static void
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2169 gen_asm(int asm0,int in,int out,int opt,int e)
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2170 {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2171 int i,e1,n;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2172 int repl = 0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2173 int repl0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2174 int assign = 0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2175 char *p;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2176
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2177 printf("# asm\n");
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2178 in = reverse0(in);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2179 out = reverse0(out);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2180 e = reverse0(e);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2181 for(i=out;i;i=cadr(i)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2182 p = (char*)cadr(car(i));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2183 e1 = car(e); e = cadr(e);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2184 repl = code_asm_operand(p,e1,ASM_OUTPUT,repl,0,0);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2185 if (car(car(repl))==REGISTER) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2186 assign = list2(assign_expr0(e1,car(repl),INT,INT),assign);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2187 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2188 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2189 repl0 = repl;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2190 n = length(repl0);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2191 for(i=in;i;i=cadr(i)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2192 p = (char*)cadr(car(i));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2193 e1 = car(e); e = cadr(e);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2194 repl = code_asm_operand(p,e1,ASM_INPUT,repl,n,repl0);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2195 if (car(car(repl))==REGISTER) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2196 g_expr_u(assign_expr0(car(repl),e1,INT,INT));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2197 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2198 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2199 repl = reverse0(repl);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2200 code_asm((char*)cadr(asm0),repl);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2201 for(i=assign;i;i=cadr(i)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2202 g_expr_u(car(i));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2203 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2204 code_free_asm_operand(repl);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2205 // no check for opt
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2206 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2207
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2208 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2209
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2210
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2211 extern NMTBL *
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2212 def(NMTBL *n)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2213 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2214 int sz,nsc,ndsp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2215 int sbit_f = bit_field_disp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2216 bit_field_disp = 0; // default is 0, recover only in bit-field
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2217
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2218 if (n==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2219 n=anonymous_nptr();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2220 n->nm = "_";
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2221 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2222 nsc=ndsp=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2223 if (stmode==EXTRN||mode==GDECL)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2224 n->ty = type; /* must be in global table/heap */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2225 if(type>0&&(car(type)==FUNCTION || car(type)==CODE)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2226 if ((mode==GDECL)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2227 fcheck(n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2228 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2229 /* function and code segment are defined using fdecl/code_decl */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2230 /* in decl() */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2231 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2232 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2233 if (mode==GSDECL||mode==LSDECL|| mode==GUDECL||mode==LUDECL) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2234 /* Struct fields name lists are in the struct type or tag. */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2235 /* Only name in the table is used. */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2236 if (car(n->ty)==BIT_FIELD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2237 bit_field_disp=sbit_f; // default is 0, recover only here.
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2238 // n->ty = list4(BIT_FIELD,type,bit_offset,bit_width);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2239 caddr(n->ty) = code_bit_field_disp(
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2240 cadr(n->ty),cadddr(n->ty),&disp,&bit_field_disp,&sz);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2241 /* bit_field_disp is next bit posision */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2242 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2243 sz = size(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2244 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2245 fields = list4(type,fields,(int)(n->nm),disp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2246 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2247 if (n->sc!=EMPTY && !(n->sc==EXTRN||n->sc==EXTRN1||n->sc==STATIC)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2248 /* redefined case */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2249 if (mode==ADECL) { /* K&R arguments case */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2250 if (n->sc==LVAR && n->ty==INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2251 else if ( n->sc==REGISTER && n->ty==INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2252 else error(RDERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2253 } else error(RDERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2254 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2255 sz = size(n->ty = type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2256 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2257 switch(mode) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2258 case GDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2259 gen_gdecl(n->nm,gpc);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2260 case STADECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2261 nsc = GVAR;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2262 ndsp = gpc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2263 if (n->dsp!=-1) /* don't set dsp if initialized static */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2264 n->dsp = ndsp; /* emit_data will override this */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2265 if (stmode==EXTRN)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2266 nsc = EXTRN;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2267 else if (stmode==STATIC)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2268 nsc = STATIC;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2269 n->sc = nsc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2270 if (stmode==LDECL) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2271 n->nm = new_static_name(n->nm,'.');
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2272 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2273 gpc +=sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2274 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2275 case GSDECL: case LSDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2276 disp += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2277 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2278 case GUDECL: case LUDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2279 if (disp < sz) disp = sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2280 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2281 case GTDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2282 nsc = TYPE;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2283 gtypedefed=glist2((int)gnptr,gtypedefed);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2284 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2285 case LTDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2286 nsc = TYPE;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2287 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2288 case ADECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2289 if(!integral(type)&&(car(type)==FUNCTION||car(type)==CODE)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2290 type=list2(POINTER,type); n->ty = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2291 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2292 fnptr->dsp=list4(type,fnptr->dsp,(int)n,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2293 n->sc = LVAR;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2294 if(type==CHAR||type==UCHAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2295 if (n->dsp==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2296 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2297 if (endian) n->dsp += size_of_int-1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2298 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2299 args += size_of_int;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2300 } else if(type==SHORT||type==USHORT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2301 if (n->dsp==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2302 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2303 if (endian) n->dsp += size_of_int-size_of_short;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2304 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2305 args += size_of_int;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2306 } else if(type>0&&(type==UNION||type==STRUCT)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2307 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2308 args += ((sz+(size_of_int-1))&~(size_of_int-1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2309 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2310 /* if (n->dsp==0) (argument list in ADECL is useless, type
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2311 list can be found in type ) */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2312 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2313 args += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2314 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2315 cadddr(fnptr->dsp)=sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2316 if(type==VOID) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2317 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2318 n->ty = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2319 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2320 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2321 case STAT: /* return (struct hoge)f() case? */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2322 case LDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2323 if (stmode==REGISTER) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2324 if(scalar(type)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2325 ndsp = get_register_var(n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2326 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2327 } else if (type==FLOAT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2328 ndsp = get_dregister_var(n,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2329 } else if (type==DOUBLE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2330 ndsp = get_dregister_var(n,1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2331 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2332 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2333 } else if (type==LONGLONG||type==ULONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2334 ndsp = get_lregister_var(n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2335 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2336 } else error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2337 nsc = car(ndsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2338 ndsp = cadr(ndsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2339 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2340 nsc = LVAR;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2341 ndsp = new_lvar(sz);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2342 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2343 n->sc = nsc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2344 n->dsp = ndsp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2345 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2346 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2347 error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2348 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2349 n->sc = nsc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2350 n->dsp = ndsp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2351 if (stmode==EXTRN)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2352 n->sc = EXTRN;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2353 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2354 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2355
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2356
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2357 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2358 emit_init_vars(void)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2359 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2360 if (!init_vars) return;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2361 init_vars = reverse0(init_vars);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2362 while(init_vars) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2363 gexpr(car(init_vars),0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2364 init_vars = cadr(init_vars);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2365 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2366 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2367
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2368 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2369 str_init_eq()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2370 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2371 // error(-1); // duplicate struct field value
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2372 return 2; // allow override keep unique
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2373 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2374
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2375 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2376 assign_data(int e, int t, NMTBL *n,int offset)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2377 {
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2378 int ass,sz,bfd;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2379
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2380 if(mode==GDECL) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2381 emit_data(e,t,n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2382 } else if(mode==STADECL) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2383 emit_data(e,t,n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2384 } else if(mode==LDECL) {
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2385 if (t==EMPTY) {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2386 /* empty space in partial initialization */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2387 return offset+cadr(e);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2388 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2389 ass = assign_expr0(
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2390 (n->sc==REGISTER||n->sc==DREGISTER||n->sc==FREGISTER||n->sc==LREGISTER)?
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2391 list3(n->sc,n->dsp,(int)n):
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2392 list2(LVAR,n->dsp+offset),
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2393 e,t,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2394 init_vars = list2(ass,init_vars);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2395 } else if(mode==SFDINIT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2396 decl_str_init=insert_ascend(decl_str_init,
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2397 list4(offset,0,e,t),str_init_eq);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2398 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2399 error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2400 return offset;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2401 }
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2402 if (t>0&&car(t)==BIT_FIELD) {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2403 sz = 0;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2404 bfd = caddr(t); /* bit_field_disp */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2405 code_bit_field_disp(cadr(t),cadddr(t),&offset,&bfd,&sz);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2406 return offset+sz;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2407 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2408 return offset+((t==EMPTY)?cadr(e):size(t));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2409 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2410
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2411 extern void
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2412 data_closing(NMTBL *n)
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2413 {
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2414 emit_data_closing(n);
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2415 }
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2416
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2417
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2418 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2419 arg_reorder(int arg,int new_arg)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2420 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2421 /* list4(type,fnptr->dsp,(int)n,size); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2422 int i,j,sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2423 int dsp = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2424 NMTBL *n,*n1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2425
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2426 /* f(a,b,c) { int c; short a; char* b;} case */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2427
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2428 // fprintf(stderr,"arg_reorder old:\n");
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2429 // for(j=new_arg;j;j=cadr(j)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2430 // n=(NMTBL *)caddr(j);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2431 // fprintf(stderr,"dsp %d %s sz %d type %d\n",n->dsp,n->nm,cadddr(j),car(j));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2432 // }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2433 // fprintf(stderr,"arg_reorder new:\n");
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2434 for(j=arg;j;j=cadr(j)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2435 n=(NMTBL *)caddr(j);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2436 for(i=new_arg;i;i=cadr(i)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2437 n1=(NMTBL *)caddr(i);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2438 if (!neqname(n1->nm,n->nm)) break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2439 // if (n1==n) break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2440 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2441 // fprintf(stderr,"dsp %d %s %s sz %d type %d\n",dsp,n->nm,n1->nm,cadddr(i),car(i));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2442 if (!i) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2443 /* f(a,b,c) { int c; } case (what?!) */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2444 i = j;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2445 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2446 if(n->sc==LVAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2447 n->dsp = dsp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2448 car(j)=car(i);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2449 caddr(j)=caddr(i);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2450 cadddr(j)=sz= cadddr(i);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2451 if (sz==1||sz==size_of_short) sz = size_of_int;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2452 dsp += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2453 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2454 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2455 // fprintf(stderr,"arg_reorder end:\n");
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2456 return arg;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2457 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2458
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2459
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2460 static NMTBL str_ret;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2461
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2462 /*
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2463 If function has structure return value, it has an extra
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2464 argument for where to write the structure. It have to be
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2465 a first argument. We add it here and we have to fix all arguments'
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2466 offset. If it is the last value, we don't have to fix, but
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2467 gcc has a first argument convention.
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2468 */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2469
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2470 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2471 fdecl_struct(int fntype)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2472 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2473 int type_save,mode_save,t,sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2474 NMTBL *n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2475
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2476 t = cadr(fntype);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2477 if (t>0 && (car(t)==STRUCT||car(t)==UNION)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2478 mode_save = mode;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2479 mode=ADECL;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2480 type_save = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2481 /* extra argument for struct return */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2482 /* this extra dummy arguments are set at calling sequence */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2483 str_ret.nm = "str_ret"; str_ret.sc = EMPTY;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2484 str_ret.dsp = 0; str_ret.ty = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2485 type=list2(POINTER,t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2486 /* fix all argument's offset */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2487 sz = size(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2488 for(t=fnptr->dsp;t;t=cadr(t)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2489 n=(NMTBL *)caddr(t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2490 n->dsp += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2491 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2492 fnptr->dsp = reverse0(fnptr->dsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2493 if ((sz=size(cadr(fntype)))==-1) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2494 else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2495 args = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2496 def(&str_ret);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2497 struct_return = list3(list2(LVAR,str_ret.dsp),sz,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2498 caddr(fnptr->ty) = glist2(POINTER,caddr(fnptr->ty));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2499 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2500 type = type_save;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2501 mode = mode_save;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2502 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2503 struct_return = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2504 fnptr->dsp = reverse0(fnptr->dsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2505 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2506 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2507
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2508 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2509 fcheck(NMTBL *n)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2510 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2511 if(!(mode==GDECL||mode==ADECL)||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2512 (car(type)!=FUNCTION&&car(type)!=CODE)) error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2513 if (n->sc==EMPTY) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2514 n->sc=EXTRN;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2515 n->ty=type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2516 } else if(is_code(n)) compatible(cadr(n->ty),cadr(type));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2517 else if(is_function(n)) compatible(cadr(n->ty),cadr(type));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2518 else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2519 error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2520 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2521 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2522
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2523 static void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2524 compatible(int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2525 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2526 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2527 if(t1!=t2) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2528 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2529 else if(car(t1)!=car(t2))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2530 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2531 else if((car(t1)==STRUCT || car(t1)==UNION) && cadr(t1)!=cadr(t2))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2532 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2533 else if(car(t1)==POINTER || car(t1)==ARRAY ||car(t1)==FUNCTION)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2534 compatible(cadr(t1),cadr(t2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2535 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2536
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2537 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2538 scalar(int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2539 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2540 return(integral(t)||car(t)==POINTER);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2541 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2542
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2543 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2544 integral(int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2545 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2546 return(t==INT||t==SIGNED||t==CHAR||t==UNSIGNED||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2547 t==UCHAR||t==SHORT||t==USHORT||t==ENUM);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2548 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2549
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2550 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2551 checkret(void)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2552 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2553 if (cslabel==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2554 if (!control) error(-1); // no execute code in switch
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2555 jmp(cslabel=fwdlabel());
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2556 } else if (retpending) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2557 ret();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2558 control=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2559 retpending=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2560 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2561 if (lastexp) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2562 gexpr(lastexp,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2563 lastexp = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2564 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2565 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2566
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2567
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2568 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2569 replace_return_struct(int func,int left) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2570 int e = caddr(func); /* arg lists */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2571 while(cadr(e)) e=cadr(e); /* find first arg */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2572 e = car(e); /* return_struct arg */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2573 cadr(e) = left;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2574 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2575
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2576
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2577 /* right value , get the value of the variable */
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2578
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2579 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2580 indirect(int t,int e1)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2581 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2582 int e2,e3,e4,offset;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2583 e2 = e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2584 offset = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2585 e3 = cadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2586 if (car(e2)==ADD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2587 e4=caddr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2588 if (car(e4)==CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2589 offset=cadr(e4);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2590 e1=e3;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2591 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2592 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2593 return list3(t,e1,offset);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2594 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2595
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2596 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2597 rvalue(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2598 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2599 int op;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2600
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2601 op = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2602 switch(type) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2603 case INT: break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2604 case UNSIGNED: break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2605 case VOID: break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2606 case CHAR: op=COP; type=INT; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2607 case UCHAR: op=COP+US; type=UNSIGNED; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2608 case SHORT: op=SOP; type=SIGNED; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2609 case USHORT: op=SOP+US; type=UNSIGNED; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2610 case LONGLONG: op=LOP; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2611 case ULONGLONG: op=LOP+US; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2612 case FLOAT: op=FOP; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2613 case DOUBLE: op=DOP; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2614 case CODE: return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2615 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2616 if (integral(type)) break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2617 switch(car(type)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2618 case ARRAY:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2619 type=list2(POINTER,cadr(type));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2620 if(car(e)==INDIRECT) return cadr(e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2621 return list2(ADDRESS,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2622 case STRUCT: case UNION:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2623 if(car(e)==RSTRUCT) return e; /* ??? */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2624 return list3(RSTRUCT,e,cadr(type) /* size */);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2625 case FUNCTION:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2626 type=cadr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2627 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2628 case CODE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2629 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2630 case POINTER:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2631 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2632 case BIT_FIELD:
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2633 return list3(RBIT_FIELD,rvalue(cadddr(e)),type);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2634 /* byte rvalue, type */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2635 type = cadr(e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2636 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2637 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2638 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2639 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2640 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2641 switch(car(e)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2642 case GVAR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2643 return(list2(RGVAR+op,cadr(e)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2644 case LVAR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2645 return(list2(RLVAR+op,cadr(e)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2646 case INDIRECT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2647 return(indirect(RINDIRECT+op,cadr(e)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2648 default:return(e); /* idempotent case? */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2649 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2650 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2651
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2652 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2653 rvalue_t(int e,int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2654 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2655 int stype = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2656 type = t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2657 e = rvalue(e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2658 type = stype;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2659 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2660 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2661
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2662 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2663 lcheck(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2664 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2665 int t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2666 if(!(scalar(type)||type==DOUBLE||type==FLOAT||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2667 type==LONGLONG||type==ULONGLONG)||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2668 (car(e)!=GVAR&&car(e)!=LVAR&&car(e)!=INDIRECT
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2669 && car(e)!=REGISTER
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2670 && car(e)!=DREGISTER
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2671 && car(e)!=FREGISTER
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2672 && car(e)!=LREGISTER)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2673 )
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2674 if ((t=car(type))<0 && t!=STRUCT && t!=UNION)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2675 error(LVERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2676 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2677
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2678 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2679 indop(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2680 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2681 if(type!=INT&&type!=UNSIGNED) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2682 if(car(type)==POINTER)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2683 type=cadr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2684 else if(car(type)==CODE || car(type)==FUNCTION)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2685 type=type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2686 else error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2687 } else
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2688 type= CHAR;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2689 if(car(e)==ADDRESS)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2690 return(cadr(e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2691 return(list2(INDIRECT,e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2692 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2693
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2694 /* filed name search */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2695
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2696 /* type = list4(s,disp,fields,tag_nptr); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2697
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2698 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2699 search_struct_type(int type,char *name,int *dsp)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2700 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2701 int t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2702 NMTBL *nptr0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2703 t = caddr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2704 if (t==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2705 nptr0=(NMTBL*)cadddr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2706 t = caddr(type) = caddr(nptr0->ty);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2707 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2708 for(;t;t = cadr(t)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2709 if (neqname((char *)caddr(t),name)==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2710 *dsp = cadddr(t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2711 return car(t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2712 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2713 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2714 return 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2715 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2716
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2717 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2718 strop(int e,int ind)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2719 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2720 int dsp = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2721
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2722 if (ind) e = indop(rvalue(e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2723 if (integral(type)||(car(type)!=STRUCT && car(type)!=UNION))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2724 e=rvalue(e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2725 /* type = list4(s,disp,fields,tag_nptr); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2726 /* print_fields(caddr(type),"strop"); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2727 type = search_struct_type(type,nptr->nm,&dsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2728 if (!type) { error(TYERR); type=INT; return e; }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2729 if(dsp) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2730 switch(car(e)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2731 case GVAR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2732 e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2733 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2734 case LVAR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2735 e=list2(LVAR,cadr(e) + dsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2736 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2737 case INDIRECT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2738 e=list2(INDIRECT,list3(ADD,cadr(e),list2(CONST,dsp)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2739 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2740 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2741 e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2742 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2743 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2744 switch(car(e)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2745 case GVAR: case LVAR: case INDIRECT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2746 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2747 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2748 e=list2(INDIRECT,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2749 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2750 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2751 if (type>0&&car(type)==BIT_FIELD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2752 // n->ty = list4(BIT_FIELD,type,bit_offset, bit_size);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2753 e=list3(BIT_FIELD,e,type);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2754 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2755 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2756 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2757
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2758 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2759 /* binary floating computation */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2760
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2761 #define DTYPE(dop) (dop==DOP?DOUBLE:FLOAT)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2762
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2763 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2764 fdbinop(int op, int e1, int e2, int t1, int t2, int dop)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2765 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2766 double d1,d2,d;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2767 int b=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2768
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2769 type= DTYPE(dop);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2770 if (dop==DOP) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2771 e1=double_value(e1,t1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2772 e2=double_value(e2,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2773 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2774 e1=float_value(e1,t1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2775 e2=float_value(e2,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2776 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2777 t1=t2=DTYPE(dop);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2778 if(car(e1)==dop+CONST&&car(e2)==dop+CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2779 d1=dcadr(e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2780 d2=dcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2781 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2782 case ADD: d=d1+d2; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2783 case SUB: d=d1-d2; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2784 case MUL: d=d1*d2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2785 case DIV:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2786 if(!d2) error(EXERR);d=d1/d2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2787 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2788 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2789 case GT: b=(d1>d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2790 case GE: b=(d1>=d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2791 case LT: b=(d1<d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2792 case LE: b=(d1<=d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2793 case EQ: b=(d1==d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2794 case NEQ: b=(d1!=d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2795 default: error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2796 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2797 type = INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2798 return list2(CONST,b);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2799 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2800 return dlist2(dop+CONST,d);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2801 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2802 if(car(e1)==dop+CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2803 if ((op==SUB||op==ADD)&&dcadr(e1)==0.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2804 return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2805 } else if (op==MUL&&dcadr(e1)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2806 return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2807 } else if (op==MUL&&-dcadr(e1)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2808 return list2(dop+MINUS,e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2809 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2810 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2811 if(car(e2)==dop+CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2812 if ((op==SUB||op==ADD)&&dcadr(e2)==0.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2813 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2814 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2815 if ((op==DIV||op==MUL)&&dcadr(e2)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2816 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2817 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2818 if ((op==DIV||op==MUL)&&-dcadr(e2)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2819 return list2(DMINUS,e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2820 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2821 if (op==SUB) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2822 op=ADD; dcadr(e2) = -dcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2823 } else if(op==DIV) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2824 if(dcadr(e2)==0.0) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2825 op=MUL; dcadr(e2)=1/dcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2826 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2827 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2828 if ((op==ADD||op==MUL) && (
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2829 car(e1)==dop+CONST ||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2830 car(e2)==DRLVAR || car(e2)==DRGVAR ||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2831 car(e2)==FRLVAR || car(e2)==FRGVAR
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2832 )) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2833 return(list3(op+dop,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2834 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2835 if(op==LT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2836 type=INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2837 return(list3(GT+dop,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2838 } else if(op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2839 type=INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2840 return(list3(GE+dop,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2841 } else if(op==GT||op==GE||op==EQ||op==NEQ) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2842 type=INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2843 return(list3(op+dop,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2844 } else if(op==ADD||op==SUB||op==MUL||op==DIV)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2845 return(list3(op+dop,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2846 else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2847 error(-1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2848 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2849 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2850 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2851
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2852 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2853 dbinop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2854 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2855 return fdbinop(op, e1, e2, t1, t2,DOP);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2856 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2857
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2858 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2859 fbinop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2860 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2861 return fdbinop(op, e1, e2, t1, t2,FOP);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2862 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2863
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2864 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2865
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2866 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2867
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2868 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2869 lbinop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2870 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2871 int e=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2872 long long le1, le2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2873 long long le = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2874 int us = (t1==ULONGLONG&&t2==ULONGLONG);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2875
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2876 if (us||(t1==ULONGLONG&&(op==LSHIFT||op==RSHIFT))) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2877 e1=ulonglong_value(e1,t1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2878 e2=ulonglong_value(e2,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2879 type = ULONGLONG;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2880 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2881 e1=longlong_value(e1,t1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2882 e2=longlong_value(e2,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2883 type = LONGLONG;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2884 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2885 if(car(e1)==LCONST&&car(e2)==LCONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2886 le1=lcadr(e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2887 le2=lcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2888 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2889 case BOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2890 le=le1|le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2891 case EOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2892 le=le1^le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2893 case BAND:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2894 le=le1&le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2895 case ADD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2896 le=le1+le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2897 case SUB:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2898 le=le1-le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2899 case MUL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2900 le=le1*le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2901 case DIV:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2902 if(!le2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2903 if (us) le=(((unsigned long long )le1)/((unsigned long long )le2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2904 else e=(le1/le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2905 case MOD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2906 if(!le2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2907 if (us) le=(((unsigned long long )le1)%((unsigned long long )le2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2908 else e=(le1%le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2909 case RSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2910 if (t1==ULONGLONG) le=(((unsigned long long)le1)<<le2); else le=le1<<le2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2911 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2912 case LSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2913 if (t1==ULONGLONG) le=(((unsigned long long)le1)>>le2); else le=le1>>le2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2914 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2915 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2916 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2917 case EQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2918 e=(le1==le2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2919 case NEQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2920 e=(le1!=le2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2921 case LT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2922 le=le1;le1=le2;le2=le;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2923 case GT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2924 if (us) e=((unsigned long long)le1>(unsigned long long)le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2925 else e=(le1>le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2926 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2927 case LE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2928 le=le1;le1=le2;le2=le;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2929 case GE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2930 if (us) e=((unsigned long long)le1>=(unsigned long long)le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2931 else e=(le1>=le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2932 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2933 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2934 error(-1); return list2(CONST,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2935 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2936 type = INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2937 return list2(CONST,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2938 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2939 return llist2(LCONST,le);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2940 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2941 if(op==LT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2942 type = INT; return(list3(GT+LOP+us,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2943 } else if(op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2944 type = INT; return(list3(GE+LOP+us,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2945 } else if(op==GT||op==GE||op==LT||op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2946 type = INT; return(list3(op+LOP+us,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2947 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2948 if(op==SUB&&car(e2)==LCONST) { op=ADD; lcadr(e2)=-lcadr(e2); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2949 if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2950 (car(e1)!=LCONST) && (
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2951 car(e2)==LRGVAR||car(e2)==LRLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2952 car(e2)==LURGVAR||car(e2)==LURLVAR
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2953 )) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2954 e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2955 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2956 if((op==MUL||op==DIV)&&car(e2)==LCONST&&lcadr(e2)==1) return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2957 if(op==BOR||op==EOR||op==BAND||op==ADD||op==SUB||op==EQ||op==NEQ)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2958 return(list3(op+LOP,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2959 if(op==LSHIFT||op==RSHIFT) return(list3(op+LOP+(t1==ULONGLONG),e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2960 return(list3(op+LOP+us,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2961 }
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2962 #endif
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2963
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2964 /* binary integer computation */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2965
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2966 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2967 binop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2968 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2969 int e=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2970 int us = (t1==UNSIGNED&&t2==UNSIGNED);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2971
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2972 if(t1>0&&car(t1)==POINTER) { e2= int_value(e2,t2); t2=INT; }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2973 else if(t2>0&&car(t2)==POINTER) { e1= int_value(e1,t1); t1=INT; }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2974 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2975 else if(t1==DOUBLE||t2==DOUBLE)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2976 return dbinop(op,e1,e2,t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2977 else if(t1==FLOAT||t2==FLOAT)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2978 return fbinop(op,e1,e2,t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2979 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2980 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2981 else if(t1==LONGLONG||t2==LONGLONG||t1==ULONGLONG||t2==ULONGLONG)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2982 return lbinop(op,e1,e2,t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2983 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2984 if(car(e1)==CONST&&car(e2)==CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2985 e1=cadr(e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2986 e2=cadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2987 type= INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2988 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2989 case BOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2990 e=e1|e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2991 case EOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2992 e=e1^e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2993 case BAND:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2994 e=e1&e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2995 case ADD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2996 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2997 if(integral(t2)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2998 e=e1+e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2999 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3000 if(car(t2)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3001 e=size(cadr(t2))*e1+e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3002 type=t2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3003 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3004 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3005 if(car(t1)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3006 e=e1+size(cadr(t1))*e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3007 type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3008 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3009 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3010 case SUB:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3011 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3012 e=e1-e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3013 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3014 if(car(t1)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3015 e=e1-size(cadr(t1))*e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3016 type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3017 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3018 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3019 case MUL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3020 e=e1*e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3021 case DIV:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3022 if(!e2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3023 if (us) e=(((unsigned)e1)/((unsigned)e2)); else e=e1/e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3024 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3025 case MOD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3026 if(!e2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3027 if (us) e=(((unsigned)e1)%((unsigned)e2)); else e=e1%e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3028 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3029 case RSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3030 if (t1==UNSIGNED) e=(((unsigned)e1)>>((unsigned)e2)); else e=e1>>e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3031 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3032 case LSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3033 if (t1==UNSIGNED) e=(((unsigned)e1)<<((unsigned)e2)); else e=e1<<e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3034 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3035 case EQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3036 e=(e1==e2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3037 case NEQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3038 e=(e1!=e2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3039 case LT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3040 e=e1;e1=e2;e2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3041 case GT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3042 if (us) e=(((unsigned)e1)>((unsigned)e2)); else e=(e1>e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3043 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3044 case LE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3045 e=e1;e1=e2;e2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3046 case GE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3047 if (us) e=(((unsigned)e1)>=((unsigned)e2)); else e=(e1>=e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3048 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3049 e=(e1<=e2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3050 default: error(-1); return list2(CONST,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3051 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3052 return list2(CONST,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3053 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3054 if(op==LT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3055 return(list3(GT+us,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3056 } else if(op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3057 return(list3(GE+us,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3058 } else if(op==GT||op==GE||op==LT||op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3059 return(list3(op+us,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3060 } else if(op==EQ||op==NEQ) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3061 return(list3(op,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3062 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3063 if(op==SUB&&car(e2)==CONST) { op=ADD; cadr(e2)=-cadr(e2); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3064 if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3065 (car(e1)!=CONST&& (
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3066 car(e2)==RGVAR||car(e2)==RLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3067 car(e2)==URGVAR||car(e2)==URLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3068 car(e2)==SRGVAR||car(e2)==SRLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3069 car(e2)==SURGVAR||car(e2)==SURLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3070 car(e2)==CRGVAR||car(e2)==CRLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3071 car(e2)==CURGVAR||car(e2)==CURLVAR
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3072 ))) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3073 e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3074 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3075 if(op==ADD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3076 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3077 if(integral(t2)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3078 if(t1==INT) type=t2;else type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3079 return(list3(ADD,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3080 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3081 if(car(t2)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3082 e=binop(MUL,e1,list2(CONST,size(cadr(t2))),t1,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3083 type=t2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3084 return(list3(ADD,e,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3085 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3086 if(car(t1)!=POINTER||!integral(t2)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3087 e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3088 type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3089 if (car(e)==CONST && cadr(e)==0)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3090 return(e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3091 if(car(e1)==ADDRESS&&car(e)==CONST&&car(cadr(e1))!=GVAR)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3092 return(list2(ADDRESS,list2(car(cadr(e1)),
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3093 cadr(cadr(e1))+cadr(e))));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3094 return(list3(ADD,e1,e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3095 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3096 if(op==SUB) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3097 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3098 if(!integral(t2)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3099 if(t1==INT) type=t2;else type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3100 return(list3(SUB,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3101 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3102 if(car(t1)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3103 if(integral(t2)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3104 e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3105 type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3106 return(list3(SUB,e1,e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3107 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3108 if(car(t2)!=POINTER)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3109 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3110 compatible(t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3111 e=list3(SUB,e1,e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3112 e=binop(DIV,e,list2(CONST,size(cadr(t1))),UNSIGNED,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3113 type= INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3114 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3115 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3116 if(!integral(t1)||!integral(t2)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3117 if(t1==INT) type=t2; else type=t1; /* ??? */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3118 if((op==MUL||op==DIV)&&car(e2)==CONST&&cadr(e2)==1) return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3119 if(op==BOR||op==EOR||op==BAND) return(list3(op,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3120 if(op==LSHIFT||op==RSHIFT) return(list3(op+(t1==UNSIGNED?US:0),e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3121 // which ops remain?
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3122 return(list3(op+us,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3123 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3124
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3125 /* coarse for function/code segments arguments */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3126
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3127 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3128 correct_type(int e,int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3129 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3130 int t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3131 /* e = rvalue(e); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3132 if (type==FLOAT && t==DOTS) { t=DOUBLE;} // fall thru
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3133 if (type==CHAR && t==DOTS) { t=INT;} // fall thru
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3134 if (t==DOTS) return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3135 if (t==UNSIGNED) e = unsigned_value(e,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3136 else if (integral(t)) e = int_value(e,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3137 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3138 else if (t==FLOAT) e = float_value(e,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3139 else if (t==DOUBLE) e = double_value(e,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3140 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3141 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3142 else if (t==LONGLONG) e = longlong_value(e,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3143 else if (t==ULONGLONG) e = ulonglong_value(e,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3144 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3145 else if ((t1=car(t))==STRUCT||t1==UNION) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3146 if(size(t)!=size(type)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3147 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3148 type = t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3149 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3150 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3151
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3152
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3153 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3154 cexpr(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3155 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3156 if (car(e) != CONST) error(CNERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3157 return (cadr(e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3158 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3159
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3160 #define is_long_type(type) (type==LONGLONG||type==ULONGLONG)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3161
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3162 #if BIT_FIELD_CODE
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3163 static int
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3164 bit_field(int e1,int t)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3165 {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3166 g_expr(e1);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3167 code_bit_field(cadr(t) /* type */,
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3168 caddr(t) /* bit offset */,
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3169 USE_CREG);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3170 return cadr(t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3171 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3172
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3173 static int
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3174 bit_field_repl(int e1,int e2,int t)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3175 {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3176 /* e1 = e2 */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3177 int lo = is_long_type(cadr(t));
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3178 g_expr(e2);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3179 if (lo) emit_lpush(); else emit_push();
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3180 g_expr(e1);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3181 code_bit_replace(USE_CREG,(e2=lo?emit_lpop():pop_register()),
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3182 t /* type */,caddr(t) /* bit offset */);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3183 if (lo) emit_lpop_free(e2) else emit_pop_free(e2);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3184 return cadr(t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3185 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3186
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3187 static int
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3188 bassop(int e2,int e3,int op,int t)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3189 {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3190 int type = cadr(t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3191 /* if op==NULL e2 = e3 */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3192 /* e2 = e2 op e3; */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3193 if (car(e2)==LREGISTER||car(e2)==REGISTER||car(e2)==LVAR||car(e2)==GVAR) {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3194 g_expr(assign_expr0(e2,
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3195 list4(BFD_REPL,e2,op?list3(op,rvalue_t(e2,t),e3):e3,t),
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3196 type,type));
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3197 return type;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3198 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3199 /* new = &e2 */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3200 /* *new = *new op e3 */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3201 n = list2(LVAR,new_lvar(size_of_int));
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3202 g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT));
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3203 g_expr(assign_expr0(list2(INDIRECT,n),
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3204 list4(BFD_REPL,n,op?list3(op,n,e3):e3,t),
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3205 type,type));
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3206 free_lvar(cadr(n));
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3207 return type;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3208 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3209
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3210 static int
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3211 bassign(int e2,int e3,int t)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3212 {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3213 return bassop(e2,e3,0,t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3214 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3215
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3216 #endif
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3217
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3218 /* temporal local variable free list */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3219
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3220 static int lvar_list,lvar_free_list;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3221
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3222 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3223 new_lvar0(int sz)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3224 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3225 return disp -= sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3226 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3227
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3228 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3229 new_lvar(int size)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3230 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3231 int lvar,plvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3232
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3233 for (plvar = 0,lvar = lvar_free_list;lvar;lvar = cadr(lvar)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3234 if (caddr(lvar)==size) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3235 if (plvar) cadr(plvar) = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3236 else lvar_free_list = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3237 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3238 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3239 plvar = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3240 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3241 if (!lvar) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3242 lvar_list = glist3((lvar=new_lvar0(size)),lvar_list,size);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3243 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3244 cadr(lvar) = lvar_list; lvar_list = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3245 lvar = car(lvar_list);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3246 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3247 return lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3248 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3249
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3250 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3251 free_lvar(int disp)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3252 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3253 int lvar,plvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3254
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3255 for (plvar = 0,lvar = lvar_list;lvar;lvar = cadr(lvar)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3256 if (car(lvar)==disp) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3257 if (plvar) cadr(plvar) = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3258 else lvar_list = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3259 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3260 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3261 plvar = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3262 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3263 if (!lvar) error(-1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3264 cadr(lvar) = lvar_free_list; lvar_free_list = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3265 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3266
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3267 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3268 init_free_lvar_list()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3269 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3270 int lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3271 while((lvar=lvar_list)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3272 lvar_list=cadr(lvar_list);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3273 free_glist3(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3274 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3275 while((lvar=lvar_free_list)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3276 lvar_free_list=cadr(lvar_free_list);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3277 free_glist3(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3278 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3279 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3280
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3281 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3282 gen_code_enter(char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3283 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3284 code_enter(name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3285 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3286
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3287 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3288 gen_code_enter1(int args)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3289 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3290 code_enter1(args);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3291 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3292
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3293 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3294 gen_code_leave(char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3295 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3296 code_leave(name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3297 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3298
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3299 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3300 gen_enter(char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3301 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3302 enter(name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3303 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3304
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3305 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3306 gen_enter1()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3307 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3308 enter1();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3309 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3310
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3311 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3312 gen_leave(int control, char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3313 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3314 leave(control,name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3315 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3316
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3317 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3318 gen_jmp(int l)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3319 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3320 jmp(l);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3321 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3322
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3323 /* end */