annotate mc-codegen.c @ 458:0bc9f3273aa7

*** empty log message ***
author kono
date Wed, 01 Dec 2004 23:14:50 +0900 (2004-12-01)
parents b8f95294eb77
children 2a49dfe59540
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"
454
214272c8f2da inline continue...
kono
parents: 453
diff changeset
9 #include "mc-switch.h"
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
10 #include "mc-inline.h"
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
11
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
12 int use; /* generated value will be used */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
13 char *init_src;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
14 int size_of_int;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
15 int size_of_short;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
16 int size_of_float;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
17 int size_of_double;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
18 int size_of_longlong;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
19 int bit_of_byte;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
20 int endian;
397
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
21 int disp_align;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
22
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
23 static void assign(int e1);
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
24 #if ASM_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
25 static void gen_asm(int asm0,int in,int out,int opt,int e);
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
26 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
27 static void compatible(int t1, int t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
28 static int contains(int e,int type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
29 static int contains_in_list(int e,int type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
30 static int contains_in_list_p(int e,int (*p)(int));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
31 static void iassop(int e1);
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
32 static int is_same_type(int e1,int e2);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
33 static void jump(int e1, int env);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
34 static void machinop(int e1);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
35 static int register_to_lvar(int e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
36 static void remove0(int *parent,int e) ;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
37 static void sassign(int e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
38
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
39 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
40
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
41 /* floating point */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
42
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
43 static void dassop(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
44 static void dmachinop(int e1,int d);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
45 static void dassign(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
46
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
47 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
48 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
49 static void lassop(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
50 static void lmachinop(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
51 static void lassign(int e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
52 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
53
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
54 #if BIT_FIELD_CODE
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
55 static int bit_field_repl(int e1,int e2,int t);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
56 static int bit_field(int e1,int t);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
57 static int bassign(int e1,int e2,int t);
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
58 static int bassop(int e1,int e2,int op,int t,int post);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
59 #endif
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
60
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
61 extern void
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
62 codegen_init()
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
63 {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
64 /* called only once */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
65 code_init();
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
66 }
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
67
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
68 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
69 codegen_reinit()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
70 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
71 /* called for each file */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
72 emit_reinit();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
73 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
74
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
75 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
76 codegen_decl_init()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
77 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
78 /* called before each declaration */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
79 emit_init();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
80 init_free_lvar_list();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
81 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
82
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
83 extern void
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
84 arg_register(NMTBL *fnptr)
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
85 {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
86 code_arg_register(fnptr);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
87 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
88
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
89 extern int
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
90 gexpr(int e1,int use0)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
91 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
92 if (chk) return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
93 gexpr_init();
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
94 use = use0;
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 {
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
131 int e2,e3,t,d,t1;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
132 NMTBL *n;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
133
455
563a5d29ec5e inline continue...
kono
parents: 454
diff changeset
134 if (inmode) {
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
135 return (parse = list3(ST_COMP,parse,e1));
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
136 }
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
137 if (!control && !IS_STATEMENT(car(e1))) return VOID;
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
138
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
139 for(;e1;e1=e2) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
140 code_gexpr(e1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
141
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
142 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
143 switch (car(e1)){
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
144 case GVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
145 code_gvar(e1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
146 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
147 case RGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
148 code_rgvar(e1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
149 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
150 case CRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
151 code_crgvar(e1,USE_CREG,1,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
152 return CHAR;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
153 case CURGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
154 code_crgvar(e1,USE_CREG,0,1);
165
kono
parents: 164
diff changeset
155 return UCHAR;
kono
parents: 164
diff changeset
156 case SRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
157 code_crgvar(e1,USE_CREG,1,size_of_short);
165
kono
parents: 164
diff changeset
158 return CHAR;
kono
parents: 164
diff changeset
159 case SURGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
160 code_crgvar(e1,USE_CREG,0,size_of_short);
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
161 return UCHAR;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
162 case LVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
163 code_lvar(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
164 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
165 case REGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
166 code_register(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
167 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
168 #if FLOAT_CODE
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
169 case DREGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
170 code_dregister(e2,USE_CREG,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
171 return DOUBLE;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
172 case FREGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
173 code_dregister(e2,USE_CREG,0);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
174 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
175 #endif
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
176 #if LONGLONG_CODE
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
177 case LREGISTER:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
178 code_lregister(e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
179 return LONGLONG;
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
180 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
181 case RLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
182 code_rlvar(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
183 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
184 case CRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
185 code_crlvar(e2,USE_CREG,1,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
186 return CHAR;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
187 case CURLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
188 code_crlvar(e2,USE_CREG,0,1);
165
kono
parents: 164
diff changeset
189 return UCHAR;
kono
parents: 164
diff changeset
190 case SRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
191 code_crlvar(e2,USE_CREG,1,size_of_short);
165
kono
parents: 164
diff changeset
192 return CHAR;
kono
parents: 164
diff changeset
193 case SURLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
194 code_crlvar(e2,USE_CREG,0,size_of_short);
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
195 return UCHAR;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
196 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
197 case FRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
198 code_drlvar(e2,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
199 return FLOAT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
200 case FRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
201 code_drgvar(e1,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
202 return FLOAT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
203 case DRLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
204 code_drlvar(e2,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
205 return DOUBLE;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
206 case DRGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
207 code_drgvar(e1,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
208 return DOUBLE;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
209 #endif
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
210 #if LONGLONG_CODE
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
211 case LRLVAR:
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 LONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
214 case LRGVAR:
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 LONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
217 case LURLVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
218 code_lrlvar(e2,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
219 return ULONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
220 case LURGVAR:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
221 code_lrgvar(e1,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
222 return ULONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
223 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
224 case FNAME:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
225 code_fname((NMTBL *)(e2),USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
226 return ADDRESS;
363
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
227 case LABEL:
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
228 code_label_value(e2,USE_CREG);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
229 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
230 case CONST: /* ���������ͤ�0�Ǥ����̤ʽ����Ϥ��ʤ� */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
231 code_const(e2,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
232 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
233 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
234 case DCONST:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
235 code_dconst(e1,USE_CREG,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
236 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
237 case FCONST:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
238 code_dconst(e1,USE_CREG,0);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
239 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
240 #endif
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
241 #if LONGLONG_CODE
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
242 case LCONST:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
243 code_lconst(e1,USE_CREG);
202
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
244 return LONGLONG;
601301152d9c *** empty log message ***
kono
parents: 197
diff changeset
245 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
246 case STRING:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
247 code_string(e1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
248 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
249 case FUNCTION:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
250 t = function(e1);
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
251 return t;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
252 case CODE:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
253 jump(e2,caddr(e1));
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
254 return VOID;
455
563a5d29ec5e inline continue...
kono
parents: 454
diff changeset
255 case INLINE:
563a5d29ec5e inline continue...
kono
parents: 454
diff changeset
256 return g_expr0(pexpr(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
257 case INDIRECT:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
258 return g_expr0(e2);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
259 case RINDIRECT:
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
260 code_rindirect(e2,USE_CREG,caddr(e1),1,0); return INT;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
261 case URINDIRECT:
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
262 code_rindirect(e2,USE_CREG,caddr(e1),0,0); return UNSIGNED;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
263 case CRINDIRECT:
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
264 code_rindirect(e2,USE_CREG,caddr(e1),1,1); return CHAR;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
265 case CURINDIRECT:
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
266 code_rindirect(e2,USE_CREG,caddr(e1),0,1); return UCHAR;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
267 case SRINDIRECT:
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
268 code_rindirect(e2,USE_CREG,caddr(e1),1,size_of_short); return SHORT;
245
8a72b0afccfc *** empty log message ***
kono
parents: 240
diff changeset
269 case SURINDIRECT:
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
270 code_rindirect(e2,USE_CREG,caddr(e1),0,size_of_short); return USHORT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
271 #if FLOAT_CODE
197
b5f49f32c2ee *** empty log message ***
kono
parents: 196
diff changeset
272 case FRINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
273 return code_drindirect(e2,USE_CREG,caddr(e1),0);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
274 case DRINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
275 return code_drindirect(e2,USE_CREG,caddr(e1),1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
276 #endif
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
277 #if LONGLONG_CODE
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
278 case LRINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
279 return code_lrindirect(e2,USE_CREG,caddr(e1),0);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
280 case LURINDIRECT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
281 return code_lrindirect(e2,USE_CREG,caddr(e1),1);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
282 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
283 case ADDRESS:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
284 if (car(e2)==REGISTER||car(e2)==DREGISTER||car(e2)==FREGISTER)
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
285 return register_to_lvar(e2); /* too late? */
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
286 else
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
287 return g_expr0(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
288 case MINUS: /* �쥸�������Ф���negl��¹Ԥ���м¸���ǽ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
289 g_expr0(e2); code_neg(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
290 return INT;
212
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
291 #if LONGLONG_CODE
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
292 case LMINUS:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
293 g_expr0(e2); code_lneg(USE_CREG);
212
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
294 return LONGLONG;
32f54ab63b35 *** empty log message ***
kono
parents: 210
diff changeset
295 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
296 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
297 case DMINUS:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
298 g_expr0(e2); code_dneg(USE_CREG,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
299 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
300 case FMINUS:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
301 g_expr0(e2); code_dneg(USE_CREG,0);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
302 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
303 #endif
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
304 case CONV:
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
305 g_expr0(e2);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
306 switch(caddr(e1)) {
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
307 case I2C: code_i2c(USE_CREG); return INT;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
308 case I2S: code_i2s(USE_CREG); return INT;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
309 case U2UC: code_u2uc(USE_CREG); return UNSIGNED;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
310 case U2US: code_u2us(USE_CREG); return UNSIGNED;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
311 #if FLOAT_CODE
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
312 case I2D: code_i2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
313 case D2I: code_d2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
314 case U2D: code_u2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
315 case F2U: code_f2u(USE_CREG); return UNSIGNED;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
316 case I2F: code_i2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
317 case F2I: code_f2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
318 case U2F: code_u2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
319 case D2U: code_d2u(USE_CREG); return UNSIGNED;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
320 case D2F: code_d2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
321 case F2D: code_f2d(USE_CREG); return DOUBLE;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
322 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
323 #if LONGLONG_CODE
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
324 case I2LL: code_i2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
325 case I2ULL: code_i2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
326 case U2LL: code_u2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
327 case U2ULL: code_u2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
328 case LL2I: code_ll2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
329 case LL2U: code_ll2u(USE_CREG); return UNSIGNED;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
330 case ULL2I: code_ull2i(USE_CREG); return INT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
331 case ULL2U: code_ull2u(USE_CREG); return UNSIGNED;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
332 #if FLOAT_CODE
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
333 case D2LL: code_d2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
334 case D2ULL: code_d2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
335 case F2LL: code_f2ll(USE_CREG); return LONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
336 case F2ULL: code_f2ull(USE_CREG); return ULONGLONG;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
337 case LL2D: code_ll2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
338 case LL2F: code_ll2f(USE_CREG); return FLOAT;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
339 case ULL2D: code_ull2d(USE_CREG); return DOUBLE;
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
340 case ULL2F: code_ull2f(USE_CREG); return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
341 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
342 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
343
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
344 default:
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
345 error(-1); return INT;
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
346 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
347 case BNOT: /* ~ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
348 g_expr0(e2); code_not(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
349 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
350 case LNOT: /* ! */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
351 g_expr0(e2); code_lnot(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
352 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
353 case PREINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
354 code_preinc(e1,e2,caddr(e1),1,cadddr(e1),USE_CREG);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
355 return INT;
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
356 case UPREINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
357 code_preinc(e1,e2,caddr(e1),0,cadddr(e1),USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
358 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
359 case POSTINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
360 code_postinc(e1,e2,caddr(e1),1,cadddr(e1),USE_CREG);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
361 return INT;
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
362 case UPOSTINC:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
363 code_postinc(e1,e2,caddr(e1),0,cadddr(e1),USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
364 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
365 #if FLOAT_CODE
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
366 case DPREINC: /* ++d */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
367 code_dpreinc(e1,e2,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
368 return DOUBLE;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
369 case DPOSTINC: /* d++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
370 code_dpostinc(e1,e2,1,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
371 return DOUBLE;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
372 case FPREINC: /* ++f */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
373 code_dpreinc(e1,e2,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
374 return FLOAT;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
375 case FPOSTINC: /* f++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
376 code_dpostinc(e1,e2,0,USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
377 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
378 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
379 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
380 case LPREINC: /* ++d */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
381 code_lpreinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
382 return LONGLONG;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
383 case LPOSTINC: /* d++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
384 code_lpostinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
385 return LONGLONG;
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
386 case LUPREINC: /* ++d */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
387 code_lpreinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
388 return ULONGLONG;
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
389 case LUPOSTINC: /* d++ */
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
390 code_lpostinc(e1,e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
391 return ULONGLONG;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
392 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
393 case MUL: case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
394 case DIV: case UDIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
395 case MOD: case UMOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
396 case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT:
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
397 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
398 case UCMP: case CMPEQ: case CMPNEQ: case UCMPGE:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
399 machinop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
400 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
401 #if FLOAT_CODE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
402 case DMUL: case DDIV:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
403 case DADD: case DSUB:
250
7637295c4fb8 *** empty log message ***
kono
parents: 249
diff changeset
404 case DCMP: case DCMPGE: case DCMPEQ: case DCMPNEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
405 dmachinop(e1,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
406 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
407 case FMUL: case FDIV:
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
408 case FADD: case FSUB:
250
7637295c4fb8 *** empty log message ***
kono
parents: 249
diff changeset
409 case FCMP: case FCMPGE: case FCMPEQ: case FCMPNEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
410 dmachinop(e1,0);
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
411 return FLOAT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
412 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
413 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
414 case LMUL: case LUMUL:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
415 case LDIV: case LUDIV:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
416 case LMOD: case LUMOD:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
417 case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
418 case LADD: case LSUB: case LBAND: case LEOR: case LBOR: case LCMP:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
419 lmachinop(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
420 return INT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
421 #endif
222
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
422 case LCOND:
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
423 case DCOND:
3d214303bae9 *** empty log message ***
kono
parents: 221
diff changeset
424 case FCOND:
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
425 case COND: /* a?0:1 should consider non-brach instruction */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
426 d = (car(e1)==LCOND?LONGLONG:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
427 car(e1)==COND?INT:car(e1)==DCOND?DOUBLE:FLOAT);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
428 e2=fwdlabel();
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
429 if (caddr(e1)) {
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
430 b_expr(cadr(e1),0,e2,0);
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
431 g_expr0(caddr(e1));
388
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
432 } else { // gcc extenstion a?:DEF
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
433 bexpr(cadr(e1),0,e2); // value used
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
434 }
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
435 t = code_get_fixed_creg(USE_CREG,d);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
436 gen_jmp(e3=fwdlabel());
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
437 fwddef(e2);
191
8646a4a9cde9 *** empty log message ***
kono
parents: 189
diff changeset
438 t1=g_expr0(cadddr(e1));
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
439 code_set_fixed_creg(t,1,d);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
440 fwddef(e3);
191
8646a4a9cde9 *** empty log message ***
kono
parents: 189
diff changeset
441 return t1;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
442 case STASS:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
443 sassign(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
444 return RSTRUCT;
165
kono
parents: 164
diff changeset
445 case ASS: case CASS: case SASS:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
446 assign(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
447 return INT;
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 342
diff changeset
448 case SASSOP: case SUASSOP:
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
449 case ASSOP: case CASSOP: case CUASSOP:
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
450 iassop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
451 return INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
452 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
453 case FASS: case DASS:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
454 dassign(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
455 return DOUBLE;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
456 case DASSOP: case FASSOP:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
457 dassop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
458 return DOUBLE;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
459 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
460 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
461 case LASS:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
462 lassign(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
463 return LONGLONG;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
464 case LASSOP: case LUASSOP:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
465 lassop(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
466 return LONGLONG ;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
467 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
468 case RSTRUCT:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
469 g_expr0(e2);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
470 return RSTRUCT;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
471 case ALLOCA:
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
472 code_alloca(e2,USE_CREG);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
473 return list2(POINTER,CHAR);
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
474 case BUILTINP:
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
475 /* Too late. Should be evaluated in pexpr. */
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
476 code_const(is_const(e2),USE_CREG);
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
477 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
478 case COMMA:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
479 g_expr_u(e2);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
480 return g_expr0(caddr(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
481 case RETURN:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
482 n = (NMTBL *)e2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
483 if (retcont==0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
484 retcont=fwdlabel();
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
485 code_return(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
486 return VOID;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
487 case ENVIRONMENT:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
488 code_environment(USE_CREG);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
489 return ADDRESS;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
490 case LCALL:
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
491 code_save_stacks();
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
492 gen_jmp(e2);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
493 fwddef(caddr(e1));
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
494 return VOID;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
495 #if BIT_FIELD_CODE
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
496 case RBIT_FIELD:
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
497 return bit_field(e2,caddr(e1) /* type */);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
498 case BASS:
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
499 return bassign(e2,caddr(e1),cadr(cadddr(e1))/* type */);
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
500 case BPREINC:
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
501 return bassop(e2,list2(CONST,caddr(e1)),ADD,
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
502 cadddr(e1)/* type */,0);
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
503 case BPOSTINC:
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
504 return bassop(e2,list2(CONST,caddr(e1)),ADD,
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
505 cadddr(e1)/* type */,1);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
506 case BASSOP:
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
507 return bassop(e2,caddr(e1),car(cadddr(e1)),/* op */
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
508 cadr(cadddr(e1))/* type */,0);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
509 #endif
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
510 #if ASM_CODE
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
511 case ASM:
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
512 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
513 /* asm in (str) out (str) opt(str) expr */
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
514 return VOID;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
515 #endif
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
516 case ST_DECL: st_decl(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
517 case ST_IF: st_if(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
518 case ST_DO: st_do(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
519 case ST_WHILE: st_while(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
520 case ST_FOR: st_for(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
521 case ST_SWITCH: st_switch(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
522 case ST_COMP: st_comp(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
523 case ST_BREAK: st_break(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
524 case ST_CONTINUE: st_continue(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
525 case ST_CASE: st_case(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
526 case ST_DEFAULT: st_default(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
527 case ST_RETURN: st_return(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
528 case ST_GOTO: st_goto(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
529 case ST_ASM: st_asm(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
530 case ST_LABEL: st_label(e1); break;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
531 case ST_COMMENT: st_comment(e1); break;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
532 default:
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
533 code_bool(e1,USE_CREG); /* type? */
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
534 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
535 }
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
536 }
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
537 return VOID;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
538 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
539
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
540 static int
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
541 rop_dual(op)
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
542 {
232
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
543 // x op y => y dual(op) x
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
544 switch(op) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
545 case GT: return LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
546 case UGT: return ULT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
547 case GE: return LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
548 case UGE: return ULE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
549 case LT: return GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
550 case ULT: return UGT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
551 case LE: return GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
552 case ULE: return UGE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
553 case DOP+GT: return DOP+LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
554 case DOP+GE: return DOP+LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
555 case DOP+LT: return DOP+GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
556 case DOP+LE: return DOP+GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
557 case FOP+GT: return FOP+LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
558 case FOP+GE: return FOP+LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
559 case FOP+LT: return FOP+GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
560 case FOP+LE: return FOP+GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
561
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
562 case LOP+GT: return LOP+LT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
563 case LOP+GE: return LOP+LE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
564 case LOP+LT: return LOP+GT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
565 case LOP+LE: return LOP+GE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
566 case LOP+UGT: return FOP+ULT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
567 case LOP+UGE: return FOP+ULE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
568 case LOP+ULT: return FOP+UGT;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
569 case LOP+ULE: return FOP+UGE;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
570 }
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
571 return op;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
572 }
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
573
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
574 /* bexpr for value unused */
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
575 /* l1 ... label for branch */
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
576 /* return 0 if l1 is not used, otherwise return l1 */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
577
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
578 extern int
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
579 bexpr_u(int e1, char cond, int l1)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
580 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
581 int op = car(e1);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
582 if (chk) return l1;
292
6d4231b6f9fe switch statement prepare
kono
parents: 289
diff changeset
583 // gexpr_init();
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
584 switch(op) {
441
1edaa643458e *** empty log message ***
kono
parents: 440
diff changeset
585 case GT: case UGT: case GE: case UGE: case LT:
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
586 case ULT: case LE: case ULE:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
587 case DOP+GT: case DOP+GE: case DOP+LT: case DOP+LE:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
588 case FOP+GT: case FOP+GE: case FOP+LT: case FOP+LE:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
589 case FOP+EQ: case FOP+NEQ:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
590 case EQ: case NEQ: case DOP+EQ: case DOP+NEQ:
441
1edaa643458e *** empty log message ***
kono
parents: 440
diff changeset
591 switch(car(cadr(e1))) {
1edaa643458e *** empty log message ***
kono
parents: 440
diff changeset
592 case CONST: case DCONST: case FCONST: case LCONST:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
593 return b_expr(list3(rop_dual(op),caddr(e1),cadr(e1)),cond,l1,0);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
594 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
595 }
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
596 return b_expr(e1,cond,l1,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
597 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
598
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
599 /* bexpr for value used */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
600
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
601 extern int
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
602 bexpr(int e1, char cond, int l1)
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
603 {
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
604 int uses = use; use=1;
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
605 l1 = bexpr_u(e1, cond, l1);
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
606 use = uses;
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
607 return l1;
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
608 }
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
609
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
610 /* branch expression generator */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
611 /* if (cond?e1:!e1) goto l1 */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
612 /* 1 or 0 is return for code_bool */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
613
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
614 extern int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
615 b_expr(int e1, char cond, int l1,int err)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
616 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
617 int e2,l2,t;
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
618 if (!control) return l1;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
619 l2 = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
620 e2=cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
621 switch(car(e1)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
622 case LNOT:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
623 return b_expr(e2,!cond,l1,0);
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
624 case GT: case GE: case LT: case LE:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
625 case EQ: case NEQ:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
626 return rexpr(e1,l1,cond,INT);
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
627 return l1;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 278
diff changeset
628 case UGT: case UGE: case ULT: case ULE:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
629 return rexpr(e1,l1,cond,UNSIGNED);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
630 #if FLOAT_CODE
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
631 case DOP+GT:
194
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
632 case DOP+GE:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
633 case DOP+EQ:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
634 case DOP+NEQ:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
635 case FOP+GT:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
636 case FOP+GE:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
637 case FOP+EQ:
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
638 case FOP+NEQ:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
639 return drexpr(cadr(e1),caddr(e1),l1,car(e1),cond);
194
114e9d64b5cc *** empty log message ***
kono
parents: 191
diff changeset
640 case FOP+LT:
231
f5efe15629d4 *** empty log message ***
kono
parents: 230
diff changeset
641 case FOP+LE:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
642 case DOP+LT:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
643 case DOP+LE:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
644 return drexpr(caddr(e1),cadr(e1),l1,rop_dual(car(e1)),cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
645 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
646 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
647 case LOP+GT:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
648 case LOP+GE:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
649 case LOP+EQ:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
650 case LOP+NEQ:
210
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
651 case LOP+UGT:
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
652 case LOP+UGE:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
653 return lrexpr(cadr(e1),caddr(e1),l1,car(e1),cond);
232
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
654 case LOP+LT:
8a23c20ac92d *** empty log message ***
kono
parents: 231
diff changeset
655 case LOP+LE:
210
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
656 case LOP+ULT:
f21651f85344 *** empty log message ***
kono
parents: 206
diff changeset
657 case LOP+ULE:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
658 return lrexpr(caddr(e1),cadr(e1),l1,rop_dual(car(e1)),cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
659 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
660 case LAND:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
661 l2=bexpr(e2,0,cond?(l2=fwdlabel()):l1);
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
662 l1=bexpr_u(caddr(e1),cond,l1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
663 if(cond) fwddef(l2);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
664 return l1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
665 case LOR:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
666 l2=bexpr(e2,1,cond?l1:(l2=fwdlabel()));
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
667 l1=bexpr_u(caddr(e1),cond,l1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
668 if(!cond) fwddef(l2);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
669 return l1;
167
0197ca125567 mips short
kono
parents: 166
diff changeset
670 case CRGVAR: case CURGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
671 code_cmp_crgvar(e1,USE_CREG,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
672 return l1;
167
0197ca125567 mips short
kono
parents: 166
diff changeset
673 case SRGVAR: case SURGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
674 code_cmp_crgvar(e1,USE_CREG,size_of_short,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
675 return l1;
167
0197ca125567 mips short
kono
parents: 166
diff changeset
676 case CRLVAR: case CURLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
677 code_cmp_crlvar(e2,USE_CREG,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
678 return l1;
167
0197ca125567 mips short
kono
parents: 166
diff changeset
679 case SRLVAR: case SURLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
680 code_cmp_crlvar(e2,USE_CREG,size_of_short,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
681 return l1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
682 case RGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
683 code_cmp_rgvar(e1,USE_CREG,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
684 return l1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
685 case RLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
686 code_cmp_rlvar(e2,USE_CREG,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
687 return l1;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
688 #if FLOATC_DOE
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
689 case DRLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
690 code_cmp_drlvar(e2,USE_CREG,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
691 return l1;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
692 case FRLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
693 code_cmp_drlvar(e2,USE_CREG,0,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
694 return l1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
695 case DRGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
696 code_cmp_drgvar(e2,USE_CREG,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
697 return l1;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
698 case FRGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
699 code_cmp_drgvar(e2,USE_CREG,0,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
700 return l1;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
701 case FREGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
702 code_cmp_dregister(e2,0,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
703 return l1;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
704 case DREGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
705 code_cmp_dregister(e2,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
706 return l1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
707 case DCONST:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
708 case FCONST:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
709 if(control&&((dcadr(e2)!=0.0)^cond)) {
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
710 gen_jmp(l1); return l1;
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
711 else return 0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
712 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
713 #if LONGLONG_DOE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
714 case LRLVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
715 code_cmp_lrlvar(e2,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
716 return l1;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
717 case LRGVAR:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
718 code_cmp_lrgvar(e2,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
719 return l1;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
720 case LREGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
721 code_cmp_lregister(e2,1,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
722 return l1;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
723 case LCONST:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
724 if(control&&((lcadr(e2)!=0)^cond)) {
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
725 gen_jmp(l1); return l1;
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
726 else return 0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
727 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
728 case REGISTER:
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
729 code_cmp_register(e2,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
730 return l1;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
731 case CONST:
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
732 if(control&&((cond&&e2)||(!cond&&!e2))) {
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
733 gen_jmp(l1); return l1;
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
734 } else return 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
735 default:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
736 if(err) {
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
737 error(-1); return l1; /* recursive g_expr/b_expr */
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
738 }
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
739 t=g_expr(e1);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
740 if (!use) return l1;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
741 if (0) ;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
742 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
743 else if(t==FLOAT)
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
744 code_cmp_dregister(USE_CREG,0,l1,cond);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
745 else if(t==DOUBLE)
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
746 code_cmp_dregister(USE_CREG,1,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
747 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
748 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
749 else if(t==LONGLONG||t==ULONGLONG)
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
750 code_cmp_lregister(USE_CREG,l1,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
751 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
752 else
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
753 code_cmp_register(USE_CREG,l1,cond);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
754 return l1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
755 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
756 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
757
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
758 extern int
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
759 is_const(int e)
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
760 {
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
761 switch(car(e)) {
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
762 case CONST: case LCONST: case FCONST: case DCONST:
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
763 // case ADDRESS: what happen?
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
764 // case POINTER:
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
765 return 1;
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
766 default:
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
767 return 0;
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
768 }
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
769 }
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
770
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
771 extern int
126
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
772 is_code(NMTBL *fnptr)
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
773 {
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
774 int type = fnptr->ty;
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
775 return type==CODE|| (type>0 && car(type)==CODE);
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
776 }
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
777
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
778 extern int
126
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
779 is_function(NMTBL *fnptr)
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
780 {
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
781 int type = fnptr->ty;
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
782 return type==FUNCTION || (type>0 && car(type)==FUNCTION);
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
783 }
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
784
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
785 extern int
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
786 is_inline(NMTBL *f)
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
787 {
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
788 return (f && attr_value(f,INLINE));
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
789 }
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
790
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
791 extern int
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
792 function_type(int e1,int *dots)
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
793 {
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
794 int ret_type,t;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
795 ret_type = cadr(e1);
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
796 if (ret_type==CHAR) ret_type=INT;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
797
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
798 /* check argments type is DOTS? */
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
799 t = caddr(e1);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 305
diff changeset
800 if (/* t==0 || */ t==DOTS) *dots = 1;
305
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
801 else {
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
802 *dots = 0;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
803 for(;t;t = cadr(t)) {
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
804 if (car(t)==DOTS) *dots = 1;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
805 }
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
806 }
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
807
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
808 return ret_type;
117baacd1ed0 stdarg powerpc passed except long long (macro problem)
kono
parents: 297
diff changeset
809 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
810
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
811 static int
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
812 register_to_lvar(int e)
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
813 {
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
814 error(REG_ERR);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
815 return 0;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
816 #if 0
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
817 ����ǥ쥸��������LVAR���ѹ����Ƥ⡢�֤˹��ʤ���
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
818
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
819 NMTBL *n = (NMTBL*)caddr(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
820 int reg = cadr(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
821 int tag = car(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
822 int lvar;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
823 int t;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
824 if (!n||n==&null_nptr) error(REG_ERR);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
825 switch(tag) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
826 case REGISTER:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
827 n->dsp = new_lvar(size_of_int); t = INT; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
828 case DREGISTER:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
829 n->dsp = new_lvar(size_of_double); t = DOUBLE; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
830 case FREGISTER:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
831 n->dsp = new_lvar(size_of_float); t = DOUBLE; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
832 case LREGISTER:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
833 n->dsp = new_lvar(size_of_longlong); t = LONGLONG; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
834 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
835 error(-1);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
836 }
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
837 n->sc = LVAR;
445
kono
parents: 444
diff changeset
838 lvar = list3(LVAR,n->dsp,(int)n);
kono
parents: 444
diff changeset
839 g_expr_u(assign_expr0(list3(LVAR,n->dsp,(int)n),list3(tag,reg,(int)n),t,t));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
840 if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
841 free_register(reg);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
842 return g_expr0(lvar);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
843 #endif
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
844 }
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
845
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
846 // parallel assignment of registers.
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
847 //
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
848 // target = list3(target_regnum,next,source_regnum);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
849
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
850 extern void
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
851 parallel_rassign(int assigns)
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
852 {
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
853 int free,tmp,remains,t0,t2,src;
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
854 tmp = 0;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
855 for(;;) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
856 remains = 0;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
857 // find free target
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
858 for(free=assigns;free;free=cadr(free)) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
859 if (!caddr(free)) continue; // already done
369
cd2c80d8cf8b *** empty log message ***
kono
parents: 368
diff changeset
860 if (car(free)==caddr(free)) {
cd2c80d8cf8b *** empty log message ***
kono
parents: 368
diff changeset
861 caddr(free)=0;
cd2c80d8cf8b *** empty log message ***
kono
parents: 368
diff changeset
862 continue;
cd2c80d8cf8b *** empty log message ***
kono
parents: 368
diff changeset
863 }
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
864 remains++;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
865 t0 = car(free); // target register
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
866 // check target is free
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
867 for(src=assigns;src;src=cadr(src)) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
868 if ((t2=caddr(src)) && t0==t2) break; // target is in source
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
869 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
870 if (src==0) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
871 break; // free is a free target
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
872 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
873 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
874 if (remains==0) {
370
c6c1323be02d minor fix
kono
parents: 369
diff changeset
875 if (tmp) free_lvar(tmp);
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
876 return;
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
877 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
878 if (free) { // free target
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
879 if (t0!=caddr(free)) {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
880 if (caddr(free)>=0) {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
881 code_assign_register(t0,0,caddr(free));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
882 } else {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
883 code_rlvar(caddr(free),t0);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
884 }
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
885 }
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
886 caddr(free)=0; // mark it done
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
887 } else { // no free target
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
888 for(free=assigns;free;free=cadr(free)) {
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
889 if (caddr(free)) break; // not yet done
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
890 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
891 if (!free) error(-1);
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
892 tmp = new_lvar(size_of_int);
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
893 if (tmp>0) error(-1);
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
894 code_assign_lvar(tmp,caddr(free),0);
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 367
diff changeset
895 caddr(free) = tmp;
277
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
896 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
897 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
898 }
d5467cf30f58 Prallel Register Assignment
kono
parents: 273
diff changeset
899
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
900 /* goto arguments list */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
901 /* target list4(list2(tag,disp),cdr,ty,source_expr) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
902 /* source expr=listn(tag,...) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
903 /* source (after) list2(tag,disp) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
904 /* source list list3(e,cdr,sz) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
905
451
656ec59cd79f ia32 fix
kono
parents: 450
diff changeset
906 #define DEBUG_PARALLEL_ASSIGN 0
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
907
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
908 static int is_memory(int e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
909
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
910 /* overlap
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
911 return list of overlapped target
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
912 */
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
913
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
914 static int
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
915 overlap(int t,int sz,int target)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
916 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
917 int s,s0,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
918 int t0=cadr(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
919 int t1=t0+sz;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
920 int source;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
921 int result=0;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
922 if (!is_memory(t)) error(-1);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
923 for(;target;target=cadr(target)) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
924 for(source=caddddr(target);source;source=cadr(source)) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
925 s=car(source); s0=cadr(s);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
926 switch(car(s)) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
927 case REGISTER: case DREGISTER: case FREGISTER: case LREGISTER:
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
928 if (code_register_overlap(s,t)) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
929 result = list2(target,result);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
930 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
931 break;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
932 default:
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
933 if (is_same_type(s,t)) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
934 s1=s0+caddr(source);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
935 #if DEBUG_PARALLEL_ASSIGN>1
344
b7f07df0c0f8 fix parallel assigment bug
kono
parents: 343
diff changeset
936 printf("# overlap source %d t0 %d t1 %d\n",car(car(t)),t0,t1);
b7f07df0c0f8 fix parallel assigment bug
kono
parents: 343
diff changeset
937 printf("# overlap target %d s0 %d s1 %d\n",car(car(source)),s0,s1);
b7f07df0c0f8 fix parallel assigment bug
kono
parents: 343
diff changeset
938 printf("# overlap equal = %d\n",((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
939 #endif
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
940 if((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1))
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
941 result = list2(target,result);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
942 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
943 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
944 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
945 }
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
946 return result;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
947 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
948
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
949 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
950 remove_target(int *target,int t,int *use)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
951 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
952 int use0=*use;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
953 int reg;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
954 while(use0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
955 if (car(use0)==t) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
956 reg = car(caddr(use0));
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 344
diff changeset
957 if (reg==REGISTER||reg==FREGISTER||reg==DREGISTER||reg==LREGISTER)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
958 free_register(cadr(caddr(use0)));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
959 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
960 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
961 use0 = cadr(use0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
962 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
963 remove0(target,t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
964 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
965
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
966 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
967 save_target(int t,int s,int *target,int *use,int sz,int ty)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
968 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
969 int e1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
970 /*�������쥸����(or �����å�)���������*/
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
971 if (scalar(ty) && sz==size_of_int && (e1=get_register_var(0))!=-1) {
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
972 // e1=list3(REGISTER,e1,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
973 *use=list3(t,*use,e1);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
974 g_expr_u(assign_expr0(e1,s,ty,ty));
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
975 *target = append5(*target,t,ty,e1,list3(e1,0,sz));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
976 #if FLOAT_CODE
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
977 } else if (ty==DOUBLE && sz==size_of_double && (e1=get_dregister_var(0,1))!=-1) {
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
978 // e1=list3(DREGISTER,e1,0);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
979 *use=list3(t,*use,e1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
980 g_expr_u(assign_expr0(e1,s,ty,ty));
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
981 *target = append5(*target,t,ty,e1,list3(e1,0,sz));
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
982 } else if (ty==FLOAT && sz==size_of_float && (e1=get_dregister_var(0,0))!=-1) {
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
983 // e1=list3(FREGISTER,e1,0);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
984 *use=list3(t,*use,e1);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
985 g_expr_u(assign_expr0(e1,s,ty,ty));
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
986 *target = append5(*target,t,ty,e1,list3(e1,0,sz));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
987 #endif
205
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
988 #if LONGLONG_CODE
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
989 } else if ((ty==LONGLONG||ty==ULONGLONG)&&(e1=get_lregister_var(0))!=-1) {
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
990 // e1=list3(LREGISTER,e1,0);
205
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
991 *use=list3(t,*use,e1);
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
992 g_expr_u(assign_expr0(e1,s,ty,ty));
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
993 *target = append5(*target,t,ty,e1,list3(e1,0,sz));
205
a50f90d0b63a *** empty log message ***
kono
parents: 202
diff changeset
994 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
995 } else {
445
kono
parents: 444
diff changeset
996 g_expr_u(assign_expr0((e1=list3(LVAR,new_lvar(sz),0)),s,ty,ty));
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
997 *target = append5(*target,t,ty,e1,list3(e1,0,sz));
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
998 *use=list3(t,*use,e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
999 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1000 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1001
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1002 static int
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1003 circular_dependency(int t,int clist,int target,int history)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1004 {
451
656ec59cd79f ia32 fix
kono
parents: 450
diff changeset
1005 int t1,h,sz,s,clist1,t2;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1006
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1007 for(;clist;clist=cadr(clist)) { /* conflict list */
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1008 loop:
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1009 t1 = car(clist);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1010 for(h=history;h;h=cadr(h)) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1011 if (t1==car(h)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1012 #if DEBUG_PARALLEL_ASSIGN
451
656ec59cd79f ia32 fix
kono
parents: 450
diff changeset
1013 printf("# circular dependency %d ty %d\n",car(t1),cadr(t1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1014 #endif
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1015 return t1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1016 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1017 }
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1018 for(s=caddddr(t1);s;s=cadr(s)) { /* dependent memory sources */
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1019 sz=caddr(s);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1020 if ((clist1=overlap(car(s),sz,target))) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1021 if (!cadr(t1)&&!cadr(s)) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1022 history = list2(t,history);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1023 t = t1;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1024 clist = clist1;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1025 goto loop; // tail recursion
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1026 } else {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1027 if ((t2=circular_dependency(t1,
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1028 clist1,target,list2(t,history)))) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1029 return t2;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1030 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1031 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1032 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1033 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1034 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1035 return 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1036 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1037
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1038 // static void remove_a(int source,int s); // remove all child
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1039
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1040 static void
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1041 parallel_assign(int *target,int *processing,int *use)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1042 {
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1043 int t,s,sz,ty,target0,s1,progress;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1044 while(*target) {
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1045 progress = 0;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1046 for(target0=*target;target0; target0=cadr(target0)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1047 t=car(target0); s=cadddr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1048 sz=size(ty=caddr(target0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1049 if(car(t)==car(s) && cadr(t)==cadr(s)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1050 /*�񤭹����褬��ʬ����*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1051 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1052 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
1053 #endif
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1054 remove_target(target,t,use);
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1055 progress = 1;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1056 } else if (!(s1=overlap(t,sz,*target)) ||
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1057 (cadr(s1)==0 && car(car(s1))==t)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1058 /* �ŤʤäƤʤ��Τǰ¿����ƽ񤭹���� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1059 #if DEBUG_PARALLEL_ASSIGN
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1060 if (s1 && cadr(s1)==0)
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1061 printf("# singleton %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1062 else
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1063 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
1064 #endif
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1065 g_expr_u(assign_expr0(t,s,ty,ty));
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1066 remove_target(target,t,use);
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1067 progress = 1;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1068 } else if((t=circular_dependency(target0,s1,*target,0))) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1069 remove_target(target,car(t),use);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1070 sz=size(ty=caddr(t));
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1071 save_target(car(t),cadddr(t),target,use,sz,ty);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1072 progress = 1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1073 #if DEBUG_PARALLEL_ASSIGN
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1074 printf("# saving %d ty %d+%d sz %d\n",car(car(t)),ty,cadr(car(t)),sz);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1075 #endif
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1076 break;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1077 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1078 }
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1079 if (!progress) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1080 // can't performe parallel assign
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1081 // error(-1);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1082 target0 = *target;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1083 t=car(target0); s=cadddr(target0);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1084 sz=size(ty=caddr(target0));
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1085 #if DEBUG_PARALLEL_ASSIGN
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1086 printf("# can't progress save any %d ty %d+%d sz %d\n",car(s),ty,cadr(t),sz);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1087 #endif
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1088 remove_target(target,t,use);
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1089 save_target(t,s,target,use,sz,ty);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1090 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1091 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1092 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1093
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1094 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1095 remove0(int *parent,int e)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1096 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1097 int list;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1098 while ((list=*parent)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1099 if (car(list)==e) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1100 *parent= cadr(list); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1101 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1102 parent=&cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1103 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1104 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1105 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1106
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1107 /*
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1108
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1109 static int
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1110 remove_1(int source,int e)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1111 {
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1112 int sz;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1113 if ((sz=is_memory(e))) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1114 remove0((int*)source,e);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1115 }
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1116 return source;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1117 }
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1118
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1119 static void
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1120 remove_a(int source,int s)
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1121 {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1122 contains_p1(source,s,remove_1);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1123 }
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1124 */
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1125
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1126 // #define SAVE_ALL_NON_MEMORY
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1127
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1128 #ifdef SAVE_ALL_NON_MEMORY
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1129 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1130 is_simple(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1131 {
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1132 switch(e1) {
344
b7f07df0c0f8 fix parallel assigment bug
kono
parents: 343
diff changeset
1133 case CONST: case FNAME: case LVAR: case REGISTER: case DREGISTER:
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1134 case FREGISTER: case LREGISTER:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1135 case GVAR: case RGVAR: case RLVAR: case CRLVAR: case CRGVAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1136 case DRLVAR: case FRLVAR: case LRLVAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1137 case CURLVAR: case SURLVAR: case CURGVAR: case SURGVAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1138 return 1;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1139 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1140 return 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1141 }
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1142 #endif
344
b7f07df0c0f8 fix parallel assigment bug
kono
parents: 343
diff changeset
1143
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1144 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1145 is_same_type(int e1,int e2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1146 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1147 int ce1=car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1148 int ce2=car(e2);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1149 if (ce1==LVAR) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1150 switch(ce2) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1151 case RLVAR: case CRLVAR: case FRLVAR: case DRLVAR:
416
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1152 case SRLVAR: case SURLVAR: case CURLVAR: case LVAR:
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1153 return 1;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1154 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1155 } else if (ce2==LVAR) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1156 switch(ce1) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1157 case RLVAR: case CRLVAR: case FRLVAR: case DRLVAR:
416
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1158 case SRLVAR: case SURLVAR: case CURLVAR: case LRLVAR: case LVAR:
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1159 return 1;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1160 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1161 } else if (ce1==GVAR) {
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1162 return 0;
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1163 #if 0
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1164 switch(ce2) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1165 case RGVAR: case CRGVAR: case FRGVAR: case DRGVAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1166 case SRGVAR: case SURGVAR: case CURGVAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1167 return 1;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1168 }
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1169 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1170 } else if (ce2==GVAR) {
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1171 return 0;
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1172 #if 0
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1173 switch(ce1) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1174 case RGVAR: case CRGVAR: case FRGVAR: case DRGVAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1175 case SRGVAR: case SURGVAR: case CURGVAR: case LRGVAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1176 return 1;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1177 }
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
1178 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1179 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1180 return 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1181 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1182
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1183 static int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1184 is_memory(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1185 {
344
b7f07df0c0f8 fix parallel assigment bug
kono
parents: 343
diff changeset
1186 switch(car(e1)) {
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1187 case CRLVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1188 case CRGVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1189 case CURGVAR :
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1190 return 1;
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1191 case SURGVAR:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1192 case SRGVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1193 return size_of_short;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1194 case LVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1195 case RLVAR:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1196 case GVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1197 case REGISTER :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1198 case RGVAR:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1199 return size_of_int;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1200 case FRLVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1201 case FRGVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1202 case FREGISTER :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1203 return size_of_float;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1204 case DRLVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1205 case DRGVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1206 case DREGISTER :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1207 return size_of_double;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1208 case LRGVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1209 case LRLVAR :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1210 case LREGISTER:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1211 return size_of_longlong;
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1212 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1213 return 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1214 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1215
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1216 static int
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1217 check_source(int source,int e)
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1218 {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1219 int sz;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1220 if ((sz=is_memory(e))) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1221 source = list3(e,source,sz);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1222 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1223 return source;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1224 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1225
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1226 #define ASSIGN_STRUCT_DIVIDE 40
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1227
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1228 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1229 jump(int e1, int env)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1230 {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1231 int e2,e3,e4,sz,arg_size,ty,regs,fregs;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1232 int t0,s0,r,reg;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1233 NMTBL *code0 = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1234 int target = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1235 int processing = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1236 int use = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1237
416
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1238 /* e1 = list4(FUNCTION,code_segment,arglist,ftype); */
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1239
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1240 /* �ޤ�����������׻����ʤ��顢target ���ޤä�������� */
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1241 /* list5(target,next,ty,source,source_dependency) */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1242
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1243 arg_size = 0; regs = 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1244 fregs = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1245 for (e3 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1246 e2 = car(e3); sz = size(ty=caddr(e3));
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1247 if (scalar(ty) && (r = get_input_register_var(regs,0,1))) {
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1248 target=list5(r,target,ty,e2,0); regs++;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1249 } else if (ty==FLOAT && (r = get_input_dregister_var(fregs,0,1,0))) {
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1250 target=list5(r, target,ty,e2,0); fregs++;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1251 } else if (ty==DOUBLE && (r = get_input_dregister_var(fregs,0,1,1))) {
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1252 target=list5(r, target,ty,e2,0); fregs++;
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 344
diff changeset
1253 } else if ((ty==LONGLONG||ty==ULONGLONG) && (r = get_input_lregister_var(fregs,0,1))) {
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1254 target=list5(r, target,ty,e2,0); regs+=2;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1255 } else {
416
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1256 while(car(e2)==RSTRUCT) e2=cadr(e2);
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1257 target=list5(list3(LVAR,0,0), target,ty,e2,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1258 }
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1259 /* keep arg space for register variables */
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1260 arg_size += sz;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1261 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1262 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
1263 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1264 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1265
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1266 /* disp �����������碌�ƽ��� */
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1267 if (is_code(fnptr)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1268 if (-arg_size<disp) disp = -arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1269 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1270 if (disp_offset-arg_size<disp) disp = disp_offset-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1271 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1272
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1273 /* ʣ���ʼ�������äƷ׻����Ƥ��� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1274 /* ɬ�פʤ�ɽ��ѿ����Ѥ��롣 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1275 /* �ɽ��ѿ��ؤΥ��ե��åȤ�Ф��Ƥ��� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1276
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1277 for (e2 = target; e2; e2 = cadr(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1278 t0=car(e2); s0=cadddr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1279 sz=size(ty=caddr(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1280 if(car(t0)==LVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1281 /* �����ǡ�����襢�ɥ쥹����� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1282 cadr(t0)=-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1283 }
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1284 arg_size-=sz;
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1285 #ifdef SAVE_ALL_NON_MEMORY
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1286 if (!is_simple(car(s0))) {
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1287 #else
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1288 if (contains_p(s0,not_simple_p)) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1289 #endif
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1290 /* complex case */
445
kono
parents: 444
diff changeset
1291 g_expr_u(assign_expr0((e4=list3(LVAR,new_lvar(sz),0)),s0,ty,ty));
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1292 use=list3(ty,use,e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1293 cadddr(e2)=e4;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1294 caddddr(e2)=list3(e4,0,sz);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1295 s0=e4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1296 } else if (is_same_type(t0,s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1297 if(cadr(t0)==cadr(s0)) {
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1298 if(is_memory(s0)) {
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1299 caddddr(e2)=list3(s0,0,sz);
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1300 continue;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1301 } else
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1302 error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1303 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1304 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1305 if(is_memory(s0)) {
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1306 if (sz>8 && car(s0)==LVAR && car(t0)==LVAR
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1307 &&sz<ASSIGN_STRUCT_DIVIDE) {
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1308 /* large struct generate large save/restore */
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1309 /* divide it to avoid large copy */
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1310 #if DEBUG_PARALLEL_ASSIGN
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1311 printf("# division sz %d\n",sz);
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1312 #endif
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1313 caddr(e2) = UNSIGNED;
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1314 caddddr(e2) = list3(
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1315 cadddr(e2)=list3(LVAR,cadr(s0),0),
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1316 0, size_of_int);
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1317 #if DEBUG_PARALLEL_ASSIGN
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1318 printf("# div 0 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),size_of_int);
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1319 #endif
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1320 for(e4=size_of_int;e4<sz;) {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1321 cadr(e2) = list5(car(e2),cadr(e2),
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1322 caddr(e2),cadddr(e2),caddddr(e2));
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1323 switch(sz-e4) {
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1324 case 1: caddr(e2) = UCHAR; r = 1; break;
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1325 case 2:
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1326 case 3: caddr(e2) = USHORT; r = size_of_short; break;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1327 default: caddr(e2) = UNSIGNED; r = size_of_int;
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1328 }
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1329 if (e4==size_of_int) e3=cadr(e2);
445
kono
parents: 444
diff changeset
1330 car(e2) = list3(LVAR,cadr(t0)+e4,0);
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1331 caddddr(e2) = list3(
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1332 cadddr(e2) = list3(LVAR,cadr(s0)+e4,0),0, r);
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1333 e4 += r;
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1334 #if DEBUG_PARALLEL_ASSIGN
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1335 printf("# div 1 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),r);
434
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1336 #endif
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1337 }
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1338 e2 = e3;
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1339 continue;
6927ec51c1d7 Struct division in Parallel Assignment
kono
parents: 430
diff changeset
1340 }
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1341 caddddr(e2)=list3(s0,0,sz);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1342 #if DEBUG_PARALLEL_ASSIGN
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1343 printf("# source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),sz);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1344 #endif
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1345 } else {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
1346 /* check used sources in rather complex source */
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1347 caddddr(e2)=contains_p1(0,s0,check_source);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1348 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1349 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1350 /* compute jump address */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1351 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1352 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1353 code0=(NMTBL *)cadr(e2);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1354 if (!is_code(code0)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1355 error(TYERR); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1356 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1357 } else { /* indirect */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1358 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1359 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1360 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1361 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1362 g_expr(env);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1363 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1364 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1365
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1366 /* ����������¹� */
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
1367 parallel_assign(&target,&processing,&use);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1368 while (use) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1369 reg = car(caddr(use));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1370 if (reg==REGISTER||reg==FREGISTER||reg==DREGISTER||reg==LREGISTER)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1371 free_register(cadr(caddr(use)));
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1372 else if (car(caddr(use))==LVAR)
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1373 free_lvar(cadr(caddr(use)));
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1374 use=cadr(use);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1375 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1376 if(target) error(-1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1377
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1378 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1379 /* change the frame pointer */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1380 e3 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1381 code_frame_pointer(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1382 emit_pop_free(e3);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
1383 } else if (is_function(fnptr)) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1384 if (car(e2) != FNAME) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1385 e2 = emit_pop(0);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1386 code_fix_frame_pointer(disp_offset);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1387 code_indirect_jmp(e2);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1388 emit_pop_free(e2);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1389 return;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1390 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1391 code_fix_frame_pointer(disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1392 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1393
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1394 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1395 code_jmp(code0->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1396 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1397 e2 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1398 code_indirect_jmp(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1399 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1400 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1401 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1402
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1403 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1404 machinop(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1405 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1406 int e2,e3,op;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1407
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1408 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1409 op = car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1410 e3 = caddr(e1);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1411 if (code_const_op_p(op,e3)) {
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1412 g_expr(e2);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1413 oprtc(op,USE_CREG,e3);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1414 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1415 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1416 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1417 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1418 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1419 tosop(op,USE_CREG,(e2=pop_register()));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1420 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1421 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1422 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1423
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1424 #if FLOAT_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1425 static void
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1426 dmachinop(int e1,int d)
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1427 {
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1428 int e2,e3,op;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1429
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1430 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1431 op = car(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1432 e3 = caddr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1433 g_expr(e3);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1434 emit_dpush(d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1435 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1436 dtosop(car(e1),USE_CREG,(e2=emit_dpop(d)));
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1437 emit_dpop_free(e2,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1438 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1439 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1440 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1441
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1442 #if LONGLONG_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1443 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1444 lmachinop(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1445 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1446 int e2,e3,op;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1447
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1448 e2 = cadr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1449 op = car(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1450 e3 = caddr(e1);
213
kono
parents: 212
diff changeset
1451 if (code_lconst_op_p(op,e3)) {
kono
parents: 212
diff changeset
1452 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1453 loprtc(op,USE_CREG,e3);
213
kono
parents: 212
diff changeset
1454 return;
kono
parents: 212
diff changeset
1455 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1456 g_expr(e3);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1457 emit_lpush();
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1458 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1459 ltosop(car(e1),USE_CREG,(e2=emit_lpop()));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1460 emit_lpop_free(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1461 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1462 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1463 #endif
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1464
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1465 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1466 sassign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1467 {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1468 int e2,e3,e4,sz,xreg,det,offset;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1469
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1470 /* structure assignment */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1471 e2 = cadr(e1); /* pointer variable to the struct */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1472 e3 = cadr(e2); /* offset of the variable (distination) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1473 e4 = caddr(e1); /* right value (source) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1474 sz = cadddr(e1); /* size of struct or union */
416
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1475 if (car(e4)==RSTRUCT) {
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1476 e4 = cadr(e4);
a6ed0575d731 ARM goto code, Parallel assignment
kono
parents: 415
diff changeset
1477 }
424
485bf7dde96a ARM non-aligned bitfield
kono
parents: 421
diff changeset
1478 if (is_same_type(e2,e4)) {
485bf7dde96a ARM non-aligned bitfield
kono
parents: 421
diff changeset
1479 if (cadr(e2)==cadr(e4)) {
485bf7dde96a ARM non-aligned bitfield
kono
parents: 421
diff changeset
1480 if (use) g_expr(e4);
485bf7dde96a ARM non-aligned bitfield
kono
parents: 421
diff changeset
1481 return;
485bf7dde96a ARM non-aligned bitfield
kono
parents: 421
diff changeset
1482 }
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1483 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1484 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1485 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1486 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1487 xreg = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1488 /* ����Ū�ˤϥ��ԡ��Υ����Х�åפξ����ϼ¹Ի��ˤ����狼��ʤ� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1489 /* ���������狼����⤢�� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1490 if (is_same_type(e2,e4)) {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1491 if(cadr(e2)<cadr(e4)) { offset=sz; sz=-sz;}
417
98888da30b35 code jump fixes (not finished)
kono
parents: 416
diff changeset
1492 else offset=0;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1493 det=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1494 } else {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1495 det = 0; offset=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1496 }
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 256
diff changeset
1497 emit_copy(xreg,USE_CREG,sz,offset,1,det);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1498 emit_pop_free(xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1499 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1500 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1501
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1502 static void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1503 assign_opt(int e5,int e2,int e4,int byte)
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1504 {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1505 int reg;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1506 /* e2=e4 */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1507 if (e5==REGISTER) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1508 reg = cadr(e4);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1509 switch(car(e2)) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1510 case GVAR: code_assign_gvar(e2,reg,byte); return;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1511 case LVAR: code_assign_lvar(cadr(e2),reg,byte); return;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1512 case REGISTER: code_assign_register(cadr(e2),byte,reg); return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1513 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1514 g_expr(e2);
233
2208a18f3799 *** empty log message ***
kono
parents: 232
diff changeset
1515 code_assign(USE_CREG,byte,reg);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1516 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1517 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1518 /* e2 is register now */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1519 if (car(e2)!=REGISTER) error(-1);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1520 reg = cadr(e2);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1521 switch(e5) {
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1522 case CRGVAR:
165
kono
parents: 164
diff changeset
1523 case CURGVAR: code_crgvar(e4,reg,e5==CRGVAR,1); return;
kono
parents: 164
diff changeset
1524 case SRGVAR:
kono
parents: 164
diff changeset
1525 case SURGVAR: code_crgvar(e4,reg,e5==SRGVAR,size_of_short); return;
437
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1526 case RGVAR: case URGVAR: code_rgvar(e4,reg); return;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1527 case CRLVAR:
165
kono
parents: 164
diff changeset
1528 case CURLVAR: code_crlvar(cadr(e4),reg,e5==CRLVAR,1); return;
kono
parents: 164
diff changeset
1529 case SRLVAR:
kono
parents: 164
diff changeset
1530 case SURLVAR: code_crlvar(cadr(e4),reg,e5==SRLVAR,size_of_short); return;
437
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1531 case RLVAR: case URLVAR: code_rlvar(cadr(e4),reg); return;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1532 case GVAR: code_gvar(e4,reg); return;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1533 case LVAR: code_lvar(cadr(e4),reg); return;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1534 case CONST: code_const(cadr(e4),reg); return;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1535 case ADDRESS:
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1536 if (car(cadr(e4))==STRING) code_string(cadr(e4),reg);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1537 else code_gvar(cadr(e4),reg);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1538 return;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1539 case FNAME: code_fname((NMTBL*)cadr(e4),reg); return;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1540 case STRING: code_string(e4,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1541 default: error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1542 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1543 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1544
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1545 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1546 assign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1547 {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1548 int e2,e4,byte,e5;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1549
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
1550 byte=(car(e1) == CASS)?1:(car(e1) == SASS)?size_of_short:0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1551 /* e2=e4 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1552 e2 = cadr(e1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1553 e4 = caddr(e1);e5=car(e4);
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1554 if (is_same_type(e2,e4)&&cadr(e2)==cadr(e4)) {
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1555 if (use) g_expr(e4);
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1556 return;
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1557 }
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1558 if (!use) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1559 if (e5==REGISTER) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1560 assign_opt(e5,e2,e4,byte);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1561 return;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1562 } else if (car(e2)==REGISTER) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1563 switch(e5) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1564 case ADDRESS:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1565 if (!((car(cadr(e4))==STRING) || car(cadr(e4))==GVAR))
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1566 break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1567 case CRGVAR : case CRLVAR : case RGVAR : case RLVAR :
437
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1568 case URGVAR : case URLVAR :
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1569 case CURGVAR : case CURLVAR :
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1570 case SURGVAR : case SURLVAR :
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1571 case GVAR : case LVAR :
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1572 case CONST : case FNAME : case STRING :
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1573 assign_opt(e5,e2,e4,byte);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1574 return;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1575 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1576 }
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1577 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1578 switch(car(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1579 case GVAR: /* i=3 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1580 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1581 code_assign_gvar(e2,USE_CREG,byte);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1582 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1583 case LVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1584 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1585 code_assign_lvar(cadr(e2),USE_CREG,byte);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1586 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1587 case REGISTER:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1588 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1589 code_assign_register(cadr(e2),byte,USE_CREG);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1590 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1591 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1592 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1593 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1594 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1595 e2 = emit_pop(0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1596 code_assign(e2,byte,USE_CREG);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1597 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1598 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1599 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1600
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1601 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1602
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1603 static void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1604 dassign_opt(int e5,int e2,int e4,int d)
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1605 {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1606 int reg;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1607 /* e2=e4 */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1608 if (e5==DREGISTER||e5==FREGISTER) {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1609 reg = cadr(e4);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1610 switch(car(e2)) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1611 case GVAR: /* i=3 */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1612 code_dassign_gvar(e2,reg,d);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1613 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1614 case LVAR:
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1615 code_dassign_lvar(cadr(e2),reg,d);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1616 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1617 case DREGISTER:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1618 case FREGISTER:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1619 if (reg!=cadr(e2))
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1620 code_dassign_dregister(cadr(e2),d,reg);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1621 return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1622 default:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1623 error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1624 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1625 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1626 /* e2 is register now */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1627 if (car(e2)!=DREGISTER && car(e2)!=FREGISTER) error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1628 reg = cadr(e2);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1629 switch(e5) {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1630 case FRGVAR:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1631 case DRGVAR: code_drgvar(e4,d,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1632 case FRLVAR:
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1633 case DRLVAR: code_drlvar(cadr(e4),d,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1634 case FCONST:
264
7de200d88747 MIPS first binary run (inomplete)
kono
parents: 258
diff changeset
1635 case DCONST: code_dconst(e4,reg,d); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1636 default:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1637 error(-1);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1638 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1639 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1640
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1641 static void
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1642 dassign(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1643 {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1644 int e2,e3,e4,d,e5;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1645
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1646 /* e2=e4 */
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1647 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1648 e3 = cadr(e2);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1649 e4 = caddr(e1); e5=car(e4);
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1650 if (is_same_type(e2,e4)&&cadr(e2)==cadr(e4)) {
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1651 if (use) g_expr(e4);
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1652 return;
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1653 }
249
8313c965c0e2 *** empty log message ***
kono
parents: 246
diff changeset
1654 if (car(e1)==DASS) d=1;
8313c965c0e2 *** empty log message ***
kono
parents: 246
diff changeset
1655 else if (car(e1)==FASS) d=0;
8313c965c0e2 *** empty log message ***
kono
parents: 246
diff changeset
1656 else error(-1);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1657 if (!use) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1658 switch(e5) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1659 case DRGVAR: case DRLVAR: case DCONST:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1660 if (car(e2)!=DREGISTER) break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1661 dassign_opt(e5,e2,e4,d); return;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1662 case FRGVAR: case FRLVAR: case FCONST:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1663 if (car(e2)!=FREGISTER) break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1664 case DREGISTER: case FREGISTER:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1665 dassign_opt(e5,e2,e4,d); return;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1666 }
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1667 }
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1668 switch(car(e2)) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1669 case GVAR:
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1670 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1671 code_dassign_gvar(e2,USE_CREG,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1672 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1673 case LVAR:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1674 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1675 code_dassign_lvar(cadr(e2),USE_CREG,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1676 return;
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1677 case DREGISTER:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1678 case FREGISTER:
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1679 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1680 code_dassign_dregister(cadr(e2),d,USE_CREG);
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1681 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1682 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1683 g_expr(e2);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1684 emit_push();
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1685 g_expr(e4);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1686 e2 = emit_pop(0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1687 code_dassign(e2,USE_CREG,d);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1688 emit_pop_free(e2);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1689 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1690 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1691
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1692 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1693
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1694 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1695
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1696 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1697 lassign_opt(int e5,int e2,int e4)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1698 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1699 int reg;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1700 /* e2=e4 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1701 if (e5==LREGISTER) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1702 reg = cadr(e4);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1703 switch(car(e2)) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1704 case GVAR: /* i=3 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1705 code_lassign_gvar(e2,reg);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1706 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1707 case LVAR:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1708 code_lassign_lvar(cadr(e2),reg);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1709 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1710 case LREGISTER:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1711 if (reg!=cadr(e2))
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1712 code_lassign_lregister(cadr(e2),reg);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1713 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1714 default:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1715 error(-1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1716 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1717 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1718 /* e2 is register now */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1719 if (car(e2)!=LREGISTER) error(-1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1720 reg = cadr(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1721 switch(e5) {
437
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1722 case LRGVAR: case LURGVAR: code_lrgvar(e4,reg); return;
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1723 case LRLVAR: case LURLVAR: code_lrlvar(cadr(e4),reg); return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1724 case LCONST: code_lconst(e4,reg); return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1725 default:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1726 error(-1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1727 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1728 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1729
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1730 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1731 lassign(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1732 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1733 int e2,e3,e4,e5;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1734
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1735 /* e2=e4 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1736 e2 = cadr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1737 e3 = cadr(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1738 e4 = caddr(e1); e5=car(e4);
269
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1739 if (is_same_type(e2,e4)&&cadr(e2)==cadr(e4)) {
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1740 if (use) g_expr(e4);
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1741 return;
d9f4026de4e3 MIPS continue...
kono
parents: 264
diff changeset
1742 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1743 if (!use && (
437
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1744 (e5==LREGISTER &&(car(e2)==GVAR||car(e2)==LVAR||car(e2)==LREGISTER)) ||
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1745 (car(e2)==LREGISTER&&
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1746 (e5==LRGVAR||e5==LRLVAR||e5==LURLVAR||e5==LURGVAR||e5==LCONST))
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1747 )) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1748 lassign_opt(e5,e2,e4);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1749 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1750 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1751 switch(car(e2)) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1752 case GVAR:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1753 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1754 code_lassign_gvar(e2,USE_CREG);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1755 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1756 case LVAR:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1757 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1758 code_lassign_lvar(cadr(e2),USE_CREG);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1759 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1760 case LREGISTER:
437
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1761 g_expr(e4);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1762 code_lassign_lregister(cadr(e2),USE_CREG);
437
49d4483d5110 LRULVAR in lassign
kono
parents: 436
diff changeset
1763 return;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1764 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1765 g_expr(e2);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1766 emit_push();
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1767 g_expr(e4);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1768 e2 = emit_pop(0);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
1769 code_lassign(e2,USE_CREG);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
1770 emit_pop_free(e2);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1771 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1772 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1773
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1774 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
1775
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1776 /* numerical type conversion */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1777
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
1778 #if FLOAT_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1779 static int
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1780 double_value(int e2)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1781 {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1782 if (type>0&&car(type)==BIT_FIELD) e2=rvalue(e2);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1783 switch(car(e2)) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1784 case LCONST:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1785 #if LONGLONG_CODE
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1786 e2 = dlist2(DCONST,(double)lcadr(e2)); break;
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1787 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1788 case CONST:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1789 e2 = dlist2(DCONST,(double)cadr(e2)); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1790 case FCONST:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1791 e2 = dlist2(DCONST,dcadr(e2)); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1792 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1793 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1794 case DOUBLE: break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1795 case FLOAT: e2 = list3(CONV,rvalue(e2),F2D); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1796 case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2D); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1797 case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2D); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1798 case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2D); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1799 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1800 if(integral(type)) e2 = list3(CONV,rvalue(e2),I2D);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1801 else { error(TYERR); e2 = dlist2(DCONST,1.0); }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1802 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1803 }
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1804 type = DOUBLE;
dc81596066df type fix done.
kono
parents: 333
diff changeset
1805 return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1806 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1807
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1808 static int
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1809 float_value(int e2)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1810 {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1811 if (type>0&&car(type)==BIT_FIELD) e2=rvalue(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
1812 if (0) ;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1813 #if LONGLONG_CODE
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1814 else if (car(e2)==LCONST) e2 = dlist2(FCONST,(double)lcadr(e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1815 #endif
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1816 else if (car(e2)==CONST) e2 = dlist2(FCONST,(double)cadr(e2));
dc81596066df type fix done.
kono
parents: 333
diff changeset
1817 else if (car(e2)==DCONST) e2 = dlist2(FCONST,dcadr(e2));
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1818 else {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1819 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1820 case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2F); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1821 case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2F); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1822 case FLOAT: break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1823 case DOUBLE: e2 = list3(CONV,rvalue(e2),D2F); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1824 case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2F); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1825 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1826 if(integral(type)) e2 = list3(CONV,rvalue(e2),I2F);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1827 else { error(TYERR); e2 = dlist2(DCONST,1.0); }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1828 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1829 }
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1830 type = FLOAT;
dc81596066df type fix done.
kono
parents: 333
diff changeset
1831 return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1832 }
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
1833 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1834
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
1835 #if LONGLONG_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1836 static int
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1837 longlong_value(int e2)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1838 {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1839 if (type>0&&car(type)==BIT_FIELD) e2=rvalue(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
1840 if (0) ;
dc81596066df type fix done.
kono
parents: 333
diff changeset
1841 else if (car(e2)==CONST) e2 = llist2(LCONST,(long long)cadr(e2));
dc81596066df type fix done.
kono
parents: 333
diff changeset
1842 else if (car(e2)==LCONST) ;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1843 #if FLOAT_CODE
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1844 else if (car(e2)==DCONST||car(e2)==FCONST)
dc81596066df type fix done.
kono
parents: 333
diff changeset
1845 e2 = llist2(LCONST,(long long)dcadr(e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1846 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1847 else {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1848 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1849 case FLOAT: e2 = list3(CONV,rvalue(e2),F2LL); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1850 case DOUBLE: e2 = list3(CONV,rvalue(e2),D2LL); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1851 case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2LL); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1852 case LONGLONG: break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1853 case ULONGLONG: break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1854 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1855 if(integral(type)) e2 = list3(CONV,rvalue(e2),I2LL);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1856 else { error(TYERR); e2 = llist2(LCONST,0LL); }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1857 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1858 }
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1859 type = LONGLONG;
dc81596066df type fix done.
kono
parents: 333
diff changeset
1860 return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1861 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1862
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1863 static int
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1864 ulonglong_value(int e2)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1865 {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1866 if (type>0&&car(type)==BIT_FIELD) e2=rvalue(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
1867 if (0);
dc81596066df type fix done.
kono
parents: 333
diff changeset
1868 else if (car(e2)==CONST) e2 = llist2(LCONST,(unsigned long long)cadr(e2));
dc81596066df type fix done.
kono
parents: 333
diff changeset
1869 else if (car(e2)==LCONST) ;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1870 #if FLOAT_CODE
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1871 else if (car(e2)==DCONST||car(e2)==FCONST)
dc81596066df type fix done.
kono
parents: 333
diff changeset
1872 e2 = llist2(LCONST,(unsigned long long)dcadr(e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1873 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1874 else {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1875 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1876 case FLOAT: e2 = list3(CONV,rvalue(e2),F2ULL); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1877 case DOUBLE: e2 = list3(CONV,rvalue(e2),D2ULL); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1878 case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2ULL); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1879 case LONGLONG: break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1880 case ULONGLONG: break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1881 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1882 if(integral(type)) e2 = list3(CONV,rvalue(e2),I2ULL);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1883 else { error(TYERR); e2 = llist2(LCONST,0LL); }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1884 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1885 }
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1886 type = ULONGLONG;
dc81596066df type fix done.
kono
parents: 333
diff changeset
1887 return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1888 }
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
1889 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1890
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1891 static int
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1892 int_value(int e2)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1893 {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1894 if (type>0&&car(type)==BIT_FIELD) e2=rvalue(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
1895 if (0);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1896 else if(type>0&&car(type)==ARRAY) return e2;
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1897 else if(scalar(type)) return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1898 #if FLOAT_CODE
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1899 else if (car(e2)==DCONST||car(e2)==FCONST) e2 = list2(CONST,(int)dcadr(e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1900 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1901 #if LONGLONG_CODE
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1902 else if (car(e2)==LCONST) e2 = list2(CONST,(int)lcadr(e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1903 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1904 else {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1905 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1906 case FLOAT: e2 = list3(CONV,rvalue(e2),F2I); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1907 case DOUBLE: e2 = list3(CONV,rvalue(e2),D2I); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1908 case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2I); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1909 case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2I); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1910 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1911 error(TYERR); e2 = list2(CONST,1);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1912 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1913 }
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1914 type = INT;
dc81596066df type fix done.
kono
parents: 333
diff changeset
1915 return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1916 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1917
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1918 static int
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1919 char_value(int e2)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1920 {
370
c6c1323be02d minor fix
kono
parents: 369
diff changeset
1921 if (type!=CHAR&&type!=INT) {
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1922 e2 = list3(CONV,int_value(rvalue(e2)),I2C); type = INT;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1923 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1924 return e2;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1925 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1926
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1927 static int
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1928 short_value(int e2)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1929 {
370
c6c1323be02d minor fix
kono
parents: 369
diff changeset
1930 if (type!=SHORT&&type!=INT) {
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1931 e2 = list3(CONV,int_value(rvalue(e2)),I2S); type = INT;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1932 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1933 return e2;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1934 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1935
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1936 static int
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1937 unsigned_value(int e2)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1938 {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1939 if (type>0&&car(type)==BIT_FIELD) e2=rvalue(e2);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1940 else if(type>0&&car(type)==ARRAY) return e2;
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1941 if (0);
dc81596066df type fix done.
kono
parents: 333
diff changeset
1942 else if(scalar(type)) return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1943 #if FLOAT_CODE
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1944 else if (car(e2)==DCONST||car(e2)==FCONST) e2 = list2(CONST,(int)dcadr(e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1945 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1946 #if LONGLONG_CODE
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1947 else if (car(e2)==LCONST) e2 = list2(CONST,(unsigned)lcadr(e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1948 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1949 else {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1950 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1951 case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2U); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1952 case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2U); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1953 case FLOAT: e2 = list3(CONV,rvalue(e2),F2U); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1954 case DOUBLE: e2 = list3(CONV,rvalue(e2),D2U); break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1955 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1956 error(TYERR);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1957 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
1958 }
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
1959 type = UNSIGNED;
dc81596066df type fix done.
kono
parents: 333
diff changeset
1960 return e2;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1961 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1962
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1963 static int
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1964 uchar_value(int e2)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1965 {
370
c6c1323be02d minor fix
kono
parents: 369
diff changeset
1966 if (type!=UCHAR&&type!=UNSIGNED) {
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1967 e2 = list3(CONV,unsigned_value(rvalue(e2)),U2UC); type = UNSIGNED;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1968 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1969 return e2;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1970 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1971
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1972 static int
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1973 ushort_value(int e2)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1974 {
370
c6c1323be02d minor fix
kono
parents: 369
diff changeset
1975 if (type!=USHORT&&type!=UNSIGNED) {
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1976 e2 = list3(CONV,unsigned_value(rvalue(e2)),U2US); type = UNSIGNED;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1977 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1978 return e2;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1979 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
1980
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1981 /* assign statement */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1982
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1983 /* keep type */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1984
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1985 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1986 assign_expr0(int e1,int e2,int t,int type0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1987 int stype;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1988 stype=type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1989 type = type0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1990 e2 = rvalue(e2);
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
1991 e1=assign_expr(e1,e2,t);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1992 type=stype;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1993 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1994 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1995
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1996
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1997
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1998 /* with conversion (will destroy type global variable) */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1999
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2000 extern int
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
2001 assign_expr(int e1,int e2,int t) {
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2002 switch(t) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2003 case VOID:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2004 break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2005 case CHAR:case UCHAR:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2006 e2=(t==UCHAR)?unsigned_value(e2):int_value(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
2007 return(list3(CASS,e1,e2));
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2008 case SHORT:case USHORT:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2009 e2=(t==USHORT)?unsigned_value(e2):int_value(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
2010 return(list3(SASS,e1,e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2011 #if FLOAT_CODE
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2012 case DOUBLE:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2013 e2=double_value(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
2014 return(list3(DASS,e1,e2));
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2015 case FLOAT:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2016 e2=float_value(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
2017 return(list3(FASS,e1,e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2018 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2019 #if LONGLONG_CODE
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2020 case LONGLONG:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2021 e2=longlong_value(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
2022 return(list3(LASS,e1,e2));
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2023 case ULONGLONG:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2024 e2=ulonglong_value(e2);
dc81596066df type fix done.
kono
parents: 333
diff changeset
2025 return(list3(LASS,e1,e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2026 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2027 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2028 if(scalar(t)) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2029 e2=(t==UNSIGNED)?unsigned_value(e2):int_value(e2);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2030 return(list3(ASS,e1,e2));
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2031 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2032 switch(car(t)) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2033 case BIT_FIELD:
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2034 // type = list4(BIT_FIELD,type,
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2035 // list3(type /*store type*/,0 /*bit offset*/,bitsize));
421
ab58eea5e032 Non aligned bit field (not yet complete)
kono
parents: 420
diff changeset
2036 e2 = correct_type(e2,cadr(t)); /* value type */
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2037 return(list4(BASS,e1,e2,list2(BASS,t)));
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2038 case STRUCT:case UNION:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2039 if (size(t)!=size(type)) error(TYERR);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2040 type=t;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2041 if(car(e2)==RSTRUCT && car(cadr(e2))==FUNCTION) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2042 replace_return_struct(cadr(e2),e1);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2043 return cadr(e2);
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2044 } else {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2045 return (list4(STASS,e1,e2,size(t)));
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2046 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2047 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2048 }
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2049 error(TYERR); return list3(ASS,e1,e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2050 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2051
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2052 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2053 cond(int t,int e1,int e2,int e3)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2054 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2055 if(car(e1)==CONST) {
388
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
2056 if(cadr(e1)) {type=t;return e2?e2:e1;} else return e3;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2057 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2058 #if FLOAT_CODE
388
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
2059 if(car(e1)==DCONST) {
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
2060 if(dcadr(e1)) {type=t;return e2?e2:e1;} else return e3;
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
2061 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2062 if(type==DOUBLE||t==DOUBLE) {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2063 e3=double_value(e3);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2064 type = t; if (e2) e2=double_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2065 return(list4(DCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2066 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2067 if(type==FLOAT||t==FLOAT) {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2068 e3=float_value(e3);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2069 type = t; if (e2) e2=float_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2070 return(list4(FCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2071 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2072 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2073 #if LONGLONG_CODE
388
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
2074 if(car(e1)==LCONST) {
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
2075 if(lcadr(e1)) {type=t;return e2?e2:e1;} else return e3;
245c6033683d *** empty log message ***
kono
parents: 379
diff changeset
2076 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2077 if(type==LONGLONG||t==LONGLONG) {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2078 e3=longlong_value(e3);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2079 type = t; if (e2) e2=longlong_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2080 return(list4(LCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2081 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2082 if(type==ULONGLONG||t==ULONGLONG) {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2083 e3=ulonglong_value(e3);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2084 type = t; if (e2) e2=ulonglong_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2085 return(list4(LCOND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2086 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2087 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2088 if(type==INT||(t!=INT&&type==UNSIGNED))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2089 type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2090 /* if (t!=type) error(TYERR); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2091 return(list4(COND,e1,e2,e3));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2092 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2093
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2094 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2095 assop(int e1,int e2,int op,int t,int no_float)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2096 {
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2097 int ass,u = 0;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2098 if(!(integral(type)||type==FLOAT||type==DOUBLE||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2099 type==LONGLONG||type==ULONGLONG
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2100 )) error(TYERR);
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2101 switch(t) {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2102 #if FLOAT_CODE
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2103 case FLOAT:
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2104 if (no_float) error(TYERR);
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2105 e2=float_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2106 return(list4(FASSOP,e1,e2,op+FOP));
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2107 case DOUBLE:
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2108 if (no_float) error(TYERR);
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2109 e2=double_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2110 return(list4(DASSOP,e1,e2,op+DOP));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2111 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2112 #if LONGLONG_CODE
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2113 case LONGLONG:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2114 e2=longlong_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2115 return(list4(LASSOP,e1,e2,op+LOP));
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2116 case ULONGLONG:
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
2117 e2=ulonglong_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2118 return(list4(LASSOP,e1,e2,op+LOP+((op==MUL+AS||op==DIV+AS)?US:0)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2119 #endif
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2120 case CHAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2121 type= INT; ass = CASSOP; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2122 case SHORT:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2123 type= INT; ass = SASSOP; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2124 case INT:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2125 type= INT; ass = ASSOP; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2126 case UCHAR:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2127 type= UNSIGNED; ass = CUASSOP; u=1; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2128 case USHORT:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2129 type= UNSIGNED; ass = SUASSOP; u=1; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2130 case UNSIGNED:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2131 type= UNSIGNED; ass = ASSOP; u=1; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2132 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2133 if (t>0 && car(t)==BIT_FIELD) {
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2134 // type = list4(BIT_FIELD,type,
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2135 // list3(type /*store type*/,0 /*bit offset*/,symval));
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2136 e2 = correct_type(e2,car(caddr(t))); /* store type */
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2137 type = cadr(t); /* value type */
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2138 return(list4(BASSOP,e1,e2,list2(op,t)));
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2139 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2140 }
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2141 if (u) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2142 if (op==RSHIFT||op==LSHIFT) op=op+US;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2143 else {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2144 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2145 case UCHAR: case USHORT: case UNSIGNED:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2146 if (op==MUL||op==DIV||op==MOD) op=op+US;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2147 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2148 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2149 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2150 type=t;
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2151 if(integral(t)) return(list4(ass,e1,e2,op));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2152 /* pointer += ... */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2153 if((op!=ADD&&op!=SUB)||car(t)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2154 e2=binop(MUL,e2,list2(CONST,size(cadr(t))),INT,UNSIGNED);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2155 type=t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2156
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2157 return list4(ASSOP,e1,e2,op);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2158 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2159
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2160
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2161
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2162 static void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2163 iassop(int e1)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2164 {
165
kono
parents: 164
diff changeset
2165 int e2,e3,byte,op,sign,size;
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2166 int n,t;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2167
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2168 /* e2 op= e3 */
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2169 switch(car(e1)) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2170 case CUASSOP: byte = 1; sign = 0; size = 1; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2171 case CASSOP: byte = 1; sign = 1; size = 1; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2172 case SUASSOP: byte = size_of_short; sign = 0; size = size_of_short; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2173 case SASSOP: byte = size_of_short; sign = 1; size = size_of_short; break;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
2174 default: byte = 0; sign = 1; size = size_of_int;
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
2175 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2176 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2177 if (car(e2)==INDIRECT) e2=cadr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2178 e3 = caddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2179 op = cadddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2180
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2181 if (car(e2)==REGISTER) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2182 if (code_const_op_p(op,e3)) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2183 oprtc(op,cadr(e2),e3);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2184 } else {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2185 g_expr(e3);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2186 code_register_assop(cadr(e2),USE_CREG,op,byte);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2187 }
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2188 if (use) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2189 code_register(cadr(e2),USE_CREG);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2190 }
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2191 return;
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2192 }
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2193 if (car(e3)==CONST) {
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2194 /* e2 = e2 op e3; */
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2195 t = sign?INT:UNSIGNED;
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2196 // oprtc expected
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2197 if (car(e2)==LVAR||car(e2)==GVAR) {
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2198 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
2199 return;
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2200 }
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2201 /* new = &e2 */
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2202 /* *new = *new op e3 */
445
kono
parents: 444
diff changeset
2203 n = list3(LVAR,new_lvar(size_of_int),0);
255
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2204 g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT));
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2205 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
2206 free_lvar(cadr(n));
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2207 return;
8cd8d72286ae PowerPC long long complex function call fix.
kono
parents: 250
diff changeset
2208 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2209 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2210 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2211 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2212 code_assop(op,USE_CREG,byte,sign);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2213 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2214 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2215
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2216 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2217
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2218 static void
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2219 dassop(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2220 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2221 int e2,e3,op,d;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2222
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2223 /* e2 op= e3 */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2224 d = (car(e1) == DASSOP);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2225 e2 = cadr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2226 if (car(e2)==INDIRECT) e2=cadr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2227 e3 = caddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2228 op = cadddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2229
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2230 g_expr(e3);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
2231 if (car(e2)==DREGISTER||car(e2)==FREGISTER) {
273
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
2232 emit_dpush(d);
219
6190d24e178c long long code generation level 4
kono
parents: 218
diff changeset
2233 code_register_dassop(cadr(e2),op,d);
273
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
2234 if (use)
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
2235 code_dregister(cadr(e2),USE_CREG,d);
87b9cfc86a10 *** empty log message ***
kono
parents: 269
diff changeset
2236 return;
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
2237 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2238 emit_dpush(d);
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2239 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2240 code_dassop(op,USE_CREG,d);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2241 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2242 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2243
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2244 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2245
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2246 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2247
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2248 static int
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2249 long_sign(int op)
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2250 {
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2251 return (op==LUDIV||op==LUMOD||op==LULSHIFT||op==LURSHIFT)?ULONGLONG:LONGLONG;
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2252 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2253
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2254 static void
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2255 lassop(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2256 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2257 int e2,e3,op;
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2258 int n,t;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2259
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2260 /* e2 op= e3 */
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2261 e2 = cadr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2262 if (car(e2)==INDIRECT) e2=cadr(e2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2263 e3 = caddr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2264 op = cadddr(e1);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2265
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2266 if (car(e2)==LREGISTER) {
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2267 if (code_lconst_op_p(op,e3)) {
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2268 loprtc(op,cadr(e2),e3);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2269 if (use) {
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2270 code_lregister(cadr(e2),USE_CREG);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2271 }
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2272 return;
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2273 }
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2274 if (code_lassop_p) {
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2275 g_expr(e3);
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2276 emit_lpush();
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2277 code_register_lassop(cadr(e2),op);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2278 if (use) {
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2279 code_lregister(cadr(e2),USE_CREG);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2280 }
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2281 return;
285
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2282 }
912b54949344 register assop const ( int/long )
kono
parents: 284
diff changeset
2283 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2284 if (!code_lassop_p||car(e3)==LCONST) {
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2285 /* e2 = e2 op e3; */
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2286 t = long_sign(op);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2287 if (car(e2)==LREGISTER||car(e2)==LVAR||car(e2)==GVAR) {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2288 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
2289 return;
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2290 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2291 /* new = &e2 */
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2292 /* *new = *new op e3 */
445
kono
parents: 444
diff changeset
2293 n = list3(LVAR,new_lvar(size_of_int),0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2294 g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT));
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
2295 g_expr(assign_expr0(list2(INDIRECT,n),
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
2296 list3(op,list2(LRINDIRECT,n),e3),t,t));
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2297 free_lvar(cadr(n));
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2298 return;
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2299 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2300
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2301 g_expr(e3);
286
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2302 if (car(e2)==LREGISTER) {
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2303 emit_lpush();
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2304 code_register_lassop(cadr(e2),op);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2305 if (use)
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2306 code_lregister(cadr(e2),USE_CREG);
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2307 return;
179e22f166ef register assop fix
kono
parents: 285
diff changeset
2308 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2309 emit_lpush();
d64e9a6a66bd ia32 long long code written.
kono
parents: 233
diff changeset
2310 g_expr(e2);
221
ceae585186d9 *** empty log message ***
kono
parents: 220
diff changeset
2311 code_lassop(op,USE_CREG);
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2312 return;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2313 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2314
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2315 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2316
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2317 extern void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2318 cmpdimm(int e, int csreg,int label,int cond)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2319 {
458
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2320 if (!chk) {
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2321 if (car(csreg)==CONST) {
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2322 switch(cond) {
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2323 case 1: case 0:
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2324 if (cond ^ (cadr(csreg)==e)) gen_jmp(label);
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2325 break;
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2326 case LT:
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2327 if ((cadr(csreg)>e)) gen_jmp(label);
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2328 break;
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2329 }
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2330 } else if (car(csreg)==REGISTER) {
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2331 code_cmpdimm(e, cadr(csreg),label,cond);
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2332 } else error(-1);
0bc9f3273aa7 *** empty log message ***
kono
parents: 456
diff changeset
2333 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2334 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2335
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2336 extern int
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2337 csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2338 {
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2339 return code_csvalue();
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2340 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2341
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2342 extern void
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2343 gen_ret()
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2344 {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2345 if (chk) return;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2346 code_ret();
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2347 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2348
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2349 extern void
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2350 gen_label_call(int l)
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2351 {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2352 if (chk) return;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2353 code_label_call(l);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2354 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2355
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2356 extern int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2357 fwdlabel(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2358 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2359 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2360 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2361
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2362 static void
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2363 checkjmp(int l)
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2364 {
442
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
2365 int p = pending_jmp;
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
2366 pending_jmp = 0;
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
2367 if (p) {
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
2368 if (p!=l) {
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2369 control=0;
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2370 if (!chk)
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2371 jmp(p);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2372 }
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2373 }
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2374 }
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2375
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2376 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2377 fwddef(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2378 {
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2379 if (l==0) return;
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2380 checkjmp(l);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2381 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2382 if (!chk)
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
2383 code_label(l);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2384 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2385
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2386 extern int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2387 backdef(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2388 {
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2389 checkjmp(0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2390 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2391 if (!chk)
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
2392 code_label(labelno);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2393 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2394 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2395
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2396 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2397 def_label(int cslabel, int dlabel)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2398 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2399 int fl;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2400
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2401 checkjmp(0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2402 fl = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2403 if (control) {
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2404 gen_jmp(fl=fwdlabel());
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2405 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2406 fwddef(cslabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2407 if (dlabel)
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2408 gen_jmp(dlabel);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2409 if (fl) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2410 fwddef(fl);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2411 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2412 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2413
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2414 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2415 ret(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2416 {
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2417 if (!chk)
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2418 code_set_return_register(1);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
2419 gen_jmp(retlabel);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2420 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2421
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2422 extern void
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2423 opening(char *filename)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2424 {
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2425 emit_init();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2426 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2427 code_opening(filename);
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2428 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2429
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2430 extern void
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2431 closing()
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2432 {
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2433 int e;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2434 NMTBL *n;
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2435 for(e=inline_funcs;e;e=cadr(e)) {
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2436 n = (NMTBL*)car(e);
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2437 if (1 || n->sc==EXTRN || n->sc==EXTRN1 || has_attr(n,FNAME)) {
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2438 // global or used as pointer
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2439 pfdecl(n);
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2440 }
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2441 }
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2442 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2443 code_closing();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2444 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
2445
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2446 static int
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2447 contains_in_list(int e,int type)
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2448 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2449 while(e) {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2450 if(contains(car(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2451 e = cadr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2452 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2453 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2454 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2455
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2456 static int
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2457 contains(int e,int type)
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2458 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2459 while(e) {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2460 if (car(e)==type) return 1;
256
d80e6387c539 powerpc function call complex arugment pre computation.
kono
parents: 255
diff changeset
2461 if (!car(e)) return 0;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2462 if (LIST_ARGS(car(e))){
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2463 /* list arguments */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2464 return contains_in_list(caddr(e),type);
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2465 } else if (UNARY_ARGS(car(e))) {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2466 /* unary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2467 e = cadr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2468 continue;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2469 } else if (BINARY_ARGS(car(e))) {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2470 /* biary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2471 if (contains(cadr(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2472 e = caddr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2473 continue;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2474 } else if (TARNARY_ARGS(car(e))) {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2475 /* tarary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2476 if (contains(cadr(e), type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2477 if (contains(caddr(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2478 e = cadddr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2479 continue;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2480 } else if (NULLARY_ARGS(car(e))) {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2481 /* nullary operators */
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2482 return 0;
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2483 } else {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2484 // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2485 error(-1);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2486 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2487 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2488 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2489 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2490 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2491
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2492 static int
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2493 contains_in_list_p(int e,int (*p)(int))
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2494 {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2495 while(e) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2496 if(contains_p(car(e),p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2497 e = cadr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2498 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2499 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2500 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2501
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2502 extern int
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2503 contains_p(int e,int (*p)(int))
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2504 {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2505 while(e) {
256
d80e6387c539 powerpc function call complex arugment pre computation.
kono
parents: 255
diff changeset
2506 if (!car(e)) return 0;
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2507 if (p(car(e))) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2508 if (LIST_ARGS(car(e))){
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2509 /* list arguments */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2510 return contains_in_list_p(caddr(e),p);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2511 } else if (UNARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2512 /* unary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2513 e = cadr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2514 continue;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2515 } else if (BINARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2516 /* biary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2517 if (contains_p(cadr(e),p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2518 e = caddr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2519 continue;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2520 } else if (TARNARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2521 /* tarary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2522 if (contains_p(cadr(e), p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2523 if (contains_p(caddr(e),p)) return 1;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2524 e = cadddr(e);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2525 continue;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2526 } else if (NULLARY_ARGS(car(e))) {
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2527 /* nullary operators */
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2528 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2529 } else {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2530 // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
223
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2531 error(-1);
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2532 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2533 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2534 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2535 return 0;
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2536 }
1ac647873577 *** empty log message ***
kono
parents: 222
diff changeset
2537
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2538 static int
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2539 contains_in_list_p1(int arg,int e,int (*p)(int,int))
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2540 {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2541 while(e) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2542 arg=contains_p1(arg,car(e),p);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2543 e = cadr(e);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2544 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2545 return arg;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2546 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2547
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2548 extern int
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2549 contains_p1(int arg,int e,int (*p)(int,int))
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2550 {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2551 while(e) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2552 if (!car(e)) return arg;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2553 if (LIST_ARGS(car(e))){
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2554 /* list arguments */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2555 return contains_in_list_p1(arg,caddr(e),p);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2556 } else if (UNARY_ARGS(car(e))) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2557 /* unary operators */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2558 e = cadr(e);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2559 continue;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2560 } else if (BINARY_ARGS(car(e))) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2561 /* biary operators */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2562 arg=contains_p1(arg,cadr(e),p);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2563 e = caddr(e);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2564 continue;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2565 } else if (TARNARY_ARGS(car(e))) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2566 /* tarary operators */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2567 arg=contains_p1(arg,cadr(e), p);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2568 arg=contains_p1(arg,caddr(e),p);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2569 e = cadddr(e);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2570 continue;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2571 } else if (NULLARY_ARGS(car(e))) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2572 /* nullary operators */
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2573 arg=p(arg,e);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2574 return arg;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2575 } else {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2576 // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2577 // error(-1);
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2578 return arg;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2579 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2580 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2581 return arg;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2582 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
2583
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2584 #if ASM_CODE
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2585
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2586
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2587 /*
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2588 __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
2589 ddr));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2590 asm string : output constraint parameter : input constraint parameter : opt
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2591
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2592 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
2593 2: constraint gcc constraint sting
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2594 prefix
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2595 = overwrite by this asm for output
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2596 & 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
2597 ignored in this compiler
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2598 constraints
326
e5d40f8c4cce bit-field continue.
kono
parents: 320
diff changeset
2599 m value expression is modified (no corresponding register)
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2600 information for compiler
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2601 r register for input or output
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2602 input register, output register can be shared
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2603 0-9 same operands as outout register in input constraints
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2604 3: opt "cc", "memory"
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2605 ignored in this compiler
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2606 */
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2607
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2608 static void
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2609 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
2610 {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2611 int i,e1,n;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2612 int repl = 0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2613 int repl0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2614 int assign = 0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2615 char *p;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2616
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2617 printf("# asm\n");
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2618 in = reverse0(in);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2619 out = reverse0(out);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2620 e = reverse0(e);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2621 for(i=out;i;i=cadr(i)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2622 p = (char*)cadr(car(i));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2623 e1 = car(e); e = cadr(e);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2624 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
2625 if (car(car(repl))==REGISTER) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2626 assign = list2(assign_expr0(e1,car(repl),INT,INT),assign);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2627 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2628 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2629 repl0 = repl;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2630 n = length(repl0);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2631 for(i=in;i;i=cadr(i)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2632 p = (char*)cadr(car(i));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2633 e1 = car(e); e = cadr(e);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2634 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
2635 if (car(car(repl))==REGISTER) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2636 g_expr_u(assign_expr0(car(repl),e1,INT,INT));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2637 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2638 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2639 repl = reverse0(repl);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2640 code_asm((char*)cadr(asm0),repl);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2641 for(i=assign;i;i=cadr(i)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2642 g_expr_u(car(i));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2643 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2644 code_free_asm_operand(repl);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2645 // no check for opt
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2646 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
2647
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2648 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2649
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2650 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2651 define symbol name contents
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2652 depending on stmode, mode
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2653 define displacement
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2654 */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2655
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2656 extern NMTBL *
445
kono
parents: 444
diff changeset
2657 def(NMTBL *n,int ctmode)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2658 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2659 int sz,nsc,ndsp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2660 int sbit_f = bit_field_disp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2661 bit_field_disp = 0; // default is 0, recover only in bit-field
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2662
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2663 if (n==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2664 n=anonymous_nptr();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2665 n->nm = "_";
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2666 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2667 nsc=ndsp=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2668 if (stmode==EXTRN||mode==GDECL)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2669 n->ty = type; /* must be in global table/heap */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2670 if(type>0&&(car(type)==FUNCTION || car(type)==CODE)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2671 if ((mode==GDECL)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2672 fcheck(n);
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2673 if (ctmode) set_attr(n,KONST,0);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2674 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2675 /* function and code segment are defined using fdecl/code_decl */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2676 /* in decl() */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2677 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2678 }
335
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
2679 if (mode==GSDECL||mode==LSDECL) {
445
kono
parents: 444
diff changeset
2680 /* Struct fields name lists are in the struct type or tag. */
kono
parents: 444
diff changeset
2681 /* Only name in the table is used. Do not set n->ty! */
kono
parents: 444
diff changeset
2682 /* Struct field may volatile... where do I put? list2(VOLATILE,type)? */
332
ce85d6106119 bit field continue. (code generation done)
kono
parents: 331
diff changeset
2683 if (car(type)==BIT_FIELD) {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2684 bit_field_disp=sbit_f; // default is 0, recover only here.
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2685 // type = list4(BIT_FIELD,value type,
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2686 // list3(store type,bit offset,bit_width));
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
2687 #if BIT_FIELD_CODE
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2688 cadr(caddr(type)) = code_bit_field_disp(
332
ce85d6106119 bit field continue. (code generation done)
kono
parents: 331
diff changeset
2689 type,&disp,&bit_field_disp,&sz);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2690 /* bit_field_disp is next bit posision */
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
2691 #else
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
2692 error(-1);
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
2693 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2694 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2695 sz = size(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2696 }
336
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
2697 if (n!=&null_nptr)
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
2698 fields = list4(type,fields,(int)(n->nm),disp);
335
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
2699 } else if (mode==GUDECL||mode==LUDECL) {
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
2700 if (car(type)==BIT_FIELD) {
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2701 cadr(caddr(type)) = 0; sz = size(cadr(type));
335
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
2702 } else {
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
2703 sz = size(type);
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
2704 }
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
2705 fields = list4(type,fields,(int)(n->nm),0);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2706 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2707 if (n->sc!=EMPTY && !(n->sc==EXTRN||n->sc==EXTRN1||n->sc==STATIC)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2708 /* redefined case */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2709 if (mode==ADECL) { /* K&R arguments case */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2710 if (n->sc==LVAR && n->ty==INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2711 else if ( n->sc==REGISTER && n->ty==INT);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2712 else if ( n->sc==TYPE) {
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2713 n = lsearch(n->nm,0);
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2714 } else error(RDERR);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2715 } else error(RDERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2716 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2717 sz = size(n->ty = type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2718 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2719 switch(mode) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2720 case GDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2721 gen_gdecl(n->nm,gpc);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2722 case STADECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2723 nsc = GVAR;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2724 ndsp = gpc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2725 if (n->dsp!=-1) /* don't set dsp if initialized static */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2726 n->dsp = ndsp; /* emit_data will override this */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2727 if (stmode==EXTRN)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2728 nsc = EXTRN;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2729 else if (stmode==STATIC)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2730 nsc = STATIC;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2731 n->sc = nsc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2732 if (stmode==LDECL) {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 345
diff changeset
2733 n = new_static_name(n->nm,'.');
350
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
2734 if (!n->next) {
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
2735 n->next = local_static_list; local_static_list = n;
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
2736 }
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 347
diff changeset
2737 } else {
350
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
2738 if (!n->next) {
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
2739 n->next = global_list; global_list = n;
43099915f4c2 name table reconfigure continue...
kono
parents: 348
diff changeset
2740 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2741 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2742 gpc +=sz;
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2743 if (ctmode) set_attr(n,KONST,0);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2744 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2745 case GSDECL: case LSDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2746 disp += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2747 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2748 case GUDECL: case LUDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2749 if (disp < sz) disp = sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2750 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2751 case GTDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2752 nsc = TYPE;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2753 gtypedefed=glist2((int)gnptr,gtypedefed);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2754 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2755 case LTDECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2756 nsc = TYPE;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2757 break;
362
5cf12c7a3274 local label first try
kono
parents: 355
diff changeset
2758 case LLDECL:
363
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2759 nsc = FLABEL;
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2760 if (!inmode)
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2761 ndsp = fwdlabel();
362
5cf12c7a3274 local label first try
kono
parents: 355
diff changeset
2762 break;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2763 case ADECL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2764 if(!integral(type)&&(car(type)==FUNCTION||car(type)==CODE)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2765 type=list2(POINTER,type); n->ty = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2766 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2767 fnptr->dsp=list4(type,fnptr->dsp,(int)n,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2768 n->sc = LVAR;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2769 if(type==CHAR||type==UCHAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2770 if (n->dsp==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2771 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2772 if (endian) n->dsp += size_of_int-1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2773 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2774 args += size_of_int;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2775 } else if(type==SHORT||type==USHORT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2776 if (n->dsp==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2777 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2778 if (endian) n->dsp += size_of_int-size_of_short;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2779 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2780 args += size_of_int;
444
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
2781 #if 1
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
2782 } else if(type>0&&(car(type)==UNION||car(type)==STRUCT)) {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2783 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2784 args += ((sz+(size_of_int-1))&~(size_of_int-1));
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 342
diff changeset
2785 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2786 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2787 /* if (n->dsp==0) (argument list in ADECL is useless, type
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2788 list can be found in type ) */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2789 n->dsp = args;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2790 args += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2791 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2792 cadddr(fnptr->dsp)=sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2793 if(type==VOID) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2794 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2795 n->ty = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2796 }
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2797 if (ctmode) set_attr(n,KONST,0);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2798 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2799 case STAT: /* return (struct hoge)f() case? */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2800 case LDECL:
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2801 if (stmode==REGISTER && !inmode) {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2802 if(scalar(type)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2803 ndsp = get_register_var(n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2804 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2805 } else if (type==FLOAT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2806 ndsp = get_dregister_var(n,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2807 } else if (type==DOUBLE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2808 ndsp = get_dregister_var(n,1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2809 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2810 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2811 } else if (type==LONGLONG||type==ULONGLONG) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2812 ndsp = get_lregister_var(n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2813 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2814 } else error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2815 nsc = car(ndsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2816 ndsp = cadr(ndsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2817 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2818 nsc = LVAR;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2819 ndsp = new_lvar(sz);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2820 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2821 n->sc = nsc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2822 n->dsp = ndsp;
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2823 if (ctmode) set_attr(n,KONST,0);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2824 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2825 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2826 error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2827 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2828 n->sc = nsc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2829 n->dsp = ndsp;
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2830 if (ctmode) set_attr(n,KONST,0);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2831 if (stmode==EXTRN)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2832 n->sc = EXTRN;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2833 return n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2834 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2835
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2836
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2837 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2838 emit_init_vars(void)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2839 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2840 if (!init_vars) return;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2841 init_vars = reverse0(init_vars);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2842 while(init_vars) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2843 gexpr(car(init_vars),0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2844 init_vars = cadr(init_vars);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2845 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2846 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2847
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2848 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2849 str_init_eq()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2850 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2851 // error(-1); // duplicate struct field value
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2852 return 2; // allow override keep unique
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2853 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2854
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2855 static void
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2856 emit_data(int e, int t, NMTBL *n)
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2857 {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2858 int l;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2859 char *name;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2860 name = n->nm;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2861 if(mode!=GDECL && mode!=STADECL) {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2862 error(-1); return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2863 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2864 if (chk) return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2865 if (n->dsp != -1) {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2866 n->dsp = -1; /* initialized flag */
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2867 emit_global(name,t);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2868 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2869 switch(t) {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2870 case EMPTY:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2871 if(car(e)!=CONST) error(-1);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2872 emit_space(cadr(e));
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2873 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2874 case CHAR: case UCHAR:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2875 emit_char(cadr(e));
415
bdf900926f32 fix cpmd register
kono
parents: 409
diff changeset
2876 data_alignment++;
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2877 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2878 case SHORT: case USHORT:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2879 emit_short(cadr(e));
415
bdf900926f32 fix cpmd register
kono
parents: 409
diff changeset
2880 data_alignment++;
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2881 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2882 case INT: case UNSIGNED: case ENUM:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2883 emit_int(cadr(e));
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2884 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2885 case LONGLONG: case ULONGLONG:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2886 emit_longlong(e);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2887 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2888 case DOUBLE:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2889 emit_double(e);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2890 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2891 case FLOAT:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2892 emit_float(e);
415
bdf900926f32 fix cpmd register
kono
parents: 409
diff changeset
2893 data_alignment++;
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2894 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2895 default:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2896 if (t<0) error(-1);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2897 if (car(t)==BIT_FIELD) {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2898 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2899 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2900 if (car(t)!=POINTER&&car(t)!=ARRAY) error(-1);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2901 switch(car(e)) {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2902 case CONST:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2903 emit_int(cadr(e));
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2904 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2905 case ADDRESS:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2906 if (car(cadr(e))==GVAR)
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
2907 emit_address(((NMTBL *)caddr(cadr(e)))->nm,cadr(cadr(e)));
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2908 else error(INERR);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2909 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2910 case FNAME:
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
2911 emit_address(((NMTBL *)cadr(e))->nm,0);
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
2912 return;
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2913 case GVAR:
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
2914 emit_address(((NMTBL *)caddr(e))->nm,0);
340
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2915 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2916 case STRING:
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2917 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2918 l = emit_string_label();
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2919 ascii((char *)cadr(e));
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2920 emit_label(l);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2921 } else
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2922 ascii((char *)cadr(e));
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2923 return;
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2924 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2925 // fprintf(stderr,"# type= %d\n",t);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2926 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2927 error(INERR);
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2928 }
0150de6a3244 emit_data moved.
kono
parents: 339
diff changeset
2929
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2930 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2931 assign_data(int e, int t, NMTBL *n,int offset)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2932 {
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2933 int ass,sz,bfd;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2934
446
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
2935 if (car(e)==ADDRESS||car(e)==GVAR) {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
2936 if (scalar(t)) {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
2937 t = list2(POINTER,VOID); // fake
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
2938 } else {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
2939 error(TYERR);
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
2940 }
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
2941 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2942 if(mode==GDECL) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2943 emit_data(e,t,n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2944 } else if(mode==STADECL) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2945 emit_data(e,t,n);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2946 } else if(mode==LDECL) {
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2947 if (t==EMPTY) {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2948 /* empty space in partial initialization */
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2949 return offset+cadr(e);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2950 }
445
kono
parents: 444
diff changeset
2951 /* If this is a local declared constant, we don't have to assign.
kono
parents: 444
diff changeset
2952 But some one may take it's address. We have to generate assign.
kono
parents: 444
diff changeset
2953 */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2954 ass = assign_expr0(
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2955 (n->sc==REGISTER||n->sc==DREGISTER||n->sc==FREGISTER||n->sc==LREGISTER)?
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2956 list3(n->sc,n->dsp,(int)n):
445
kono
parents: 444
diff changeset
2957 list3(LVAR,n->dsp+offset,0),
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2958 e,t,type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2959 init_vars = list2(ass,init_vars);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2960 } else if(mode==SFDINIT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2961 decl_str_init=insert_ascend(decl_str_init,
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2962 list4(offset,0,e,t),str_init_eq);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2963 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2964 error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2965 return offset;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2966 }
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2967 if (t>0&&car(t)==BIT_FIELD) {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2968 sz = 0;
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
2969 bfd = cadr(caddr(t)); /* bit_field_disp */
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
2970 #if BIT_FIELD_CODE
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
2971 code_bit_field_disp(t,&offset,&bfd,&sz);
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
2972 #endif
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2973 return offset+sz;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
2974 }
445
kono
parents: 444
diff changeset
2975 /* constant value field */
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2976 if (offset==0 && (has_attr(n,KONST))) {
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
2977 set_attr(n,KONST,e);
445
kono
parents: 444
diff changeset
2978 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2979 return offset+((t==EMPTY)?cadr(e):size(t));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2980 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2981
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2982 extern void
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2983 data_closing(NMTBL *n)
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2984 {
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2985 if (!chk)
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
2986 emit_data_closing(n);
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2987 }
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2988
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
2989 #define ARG_REORDER_DEBUG 0
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
2990
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2991 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2992 In K&R style, order of argment list and order of argment
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2993 type decl are differnt. Fix them.
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2994 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
2995
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2996 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2997 arg_reorder(int arg,int new_arg)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2998 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2999 /* list4(type,fnptr->dsp,(int)n,size); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3000 int i,j,sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3001 int dsp = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3002 NMTBL *n,*n1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3003
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3004 /* f(a,b,c) int c; short a; char* b; { } case */
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3005 #if ARG_REORDER_DEBUG
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3006 fprintf(stderr,"arg_reorder old:\n");
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3007 for(j=new_arg;j;j=cadr(j)) {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3008 n=(NMTBL *)caddr(j);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3009 fprintf(stderr,"dsp %d %s sz %d type %d\n",n->dsp,n->nm,cadddr(j),car(j));
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3010 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3011 fprintf(stderr,"arg_reorder new:\n");
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3012 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3013 for(j=arg;j;j=cadr(j)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3014 n=(NMTBL *)caddr(j);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3015 for(i=new_arg;i;i=cadr(i)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3016 n1=(NMTBL *)caddr(i);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3017 if (!neqname(n1->nm,n->nm)) break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3018 // if (n1==n) break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3019 }
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3020 #if ARG_REORDER_DEBUG
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3021 fprintf(stderr,"dsp %d %s %s sz %d type %d\n",dsp,n->nm,n1->nm,cadddr(i),car(i));
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3022 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3023 if (!i) {
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3024 /* f(a,b,c) int c; { } case (what?!) */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3025 i = j;
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3026 n1 = n;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3027 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3028 if(n->sc==LVAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3029 n->dsp = dsp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3030 car(j)=car(i);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3031 caddr(j)=caddr(i);
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3032 n1->dsp = n->dsp;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3033 n->ty = n1->ty;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3034 n->sc = n1->sc;
445
kono
parents: 444
diff changeset
3035 n->attr = n1->attr;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3036 cadddr(j)=sz= cadddr(i);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3037 if (sz==1||sz==size_of_short) sz = size_of_int;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3038 dsp += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3039 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3040 }
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3041 #if ARG_REORDER_DEBUG
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3042 fprintf(stderr,"arg_reorder end:\n");
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3043 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3044 return arg;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3045 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3046
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3047
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3048 static NMTBL str_ret;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3049
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3050 /*
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3051 If function has structure return value, it has an extra
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3052 argument for where to write the structure. It have to be
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3053 a first argument. We add it here and we have to fix all arguments'
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3054 offset. If it is the last value, we don't have to fix, but
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3055 gcc has a first argument convention.
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3056 */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3057
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3058 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3059 fdecl_struct(int fntype)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3060 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3061 int type_save,mode_save,t,sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3062 NMTBL *n;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3063
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3064 t = cadr(fntype);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3065 if (t>0 && (car(t)==STRUCT||car(t)==UNION)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3066 mode_save = mode;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3067 mode=ADECL;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3068 type_save = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3069 /* extra argument for struct return */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3070 /* this extra dummy arguments are set at calling sequence */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3071 str_ret.nm = "str_ret"; str_ret.sc = EMPTY;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3072 str_ret.dsp = 0; str_ret.ty = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3073 type=list2(POINTER,t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3074 /* fix all argument's offset */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3075 sz = size(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3076 for(t=fnptr->dsp;t;t=cadr(t)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3077 n=(NMTBL *)caddr(t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3078 n->dsp += sz;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3079 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3080 fnptr->dsp = reverse0(fnptr->dsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3081 if ((sz=size(cadr(fntype)))==-1) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3082 else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3083 args = 0;
445
kono
parents: 444
diff changeset
3084 def(&str_ret,0);
kono
parents: 444
diff changeset
3085 struct_return = list3(list3(LVAR,str_ret.dsp,0),sz,type);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3086 caddr(fnptr->ty) = glist2(POINTER,caddr(fnptr->ty));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3087 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3088 type = type_save;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3089 mode = mode_save;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3090 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3091 struct_return = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3092 fnptr->dsp = reverse0(fnptr->dsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3093 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3094 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3095
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3096 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3097 fcheck(NMTBL *n)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3098 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3099 if(!(mode==GDECL||mode==ADECL)||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3100 (car(type)!=FUNCTION&&car(type)!=CODE)) error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3101 if (n->sc==EMPTY) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3102 n->sc=EXTRN;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3103 n->ty=type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3104 } else if(is_code(n)) compatible(cadr(n->ty),cadr(type));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3105 else if(is_function(n)) compatible(cadr(n->ty),cadr(type));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3106 else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3107 error(DCERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3108 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3109 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3110
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3111 static void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3112 compatible(int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3113 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3114 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3115 if(t1!=t2) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3116 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3117 else if(car(t1)!=car(t2))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3118 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3119 else if((car(t1)==STRUCT || car(t1)==UNION) && cadr(t1)!=cadr(t2))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3120 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3121 else if(car(t1)==POINTER || car(t1)==ARRAY ||car(t1)==FUNCTION)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3122 compatible(cadr(t1),cadr(t2));
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 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3126 scalar(int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3127 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3128 return(integral(t)||car(t)==POINTER);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3129 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3130
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3131 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3132 integral(int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3133 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3134 return(t==INT||t==SIGNED||t==CHAR||t==UNSIGNED||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3135 t==UCHAR||t==SHORT||t==USHORT||t==ENUM);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3136 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3137
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3138 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3139 checkret(void)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3140 {
455
563a5d29ec5e inline continue...
kono
parents: 454
diff changeset
3141 if (inmode) error(-1);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3142 if (cslabel==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3143 if (!control) error(-1); // no execute code in switch
442
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
3144 checkjmp(0);
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
3145 control=0;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3146 jmp(cslabel=fwdlabel());
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3147 } else if (retpending) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3148 ret();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3149 control=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3150 retpending=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3151 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3152 if (lastexp) {
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
3153 if(!control) error(-1);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3154 gexpr(lastexp,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3155 lastexp = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3156 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3157 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3158
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3159
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3160 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3161 replace_return_struct(int func,int left) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3162 int e = caddr(func); /* arg lists */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3163 while(cadr(e)) e=cadr(e); /* find first arg */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3164 e = car(e); /* return_struct arg */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3165 cadr(e) = left;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3166 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3167
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
3168
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3169 /* right value , get the value of the variable */
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
3170
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3171 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3172 indirect(int t,int e1)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3173 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3174 int e2,e3,e4,offset;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3175 e2 = e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3176 offset = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3177 e3 = cadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3178 if (car(e2)==ADD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3179 e4=caddr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3180 if (car(e4)==CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3181 offset=cadr(e4);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3182 e1=e3;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3183 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3184 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3185 return list3(t,e1,offset);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3186 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3187
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3188 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3189 rvalue(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3190 {
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
3191 int op,c;
445
kono
parents: 444
diff changeset
3192 NMTBL *n;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3193
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
3194 if (e==0) error(-1);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3195 op = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3196 switch(type) {
333
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3197 case INT: break;
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3198 case UNSIGNED: break;
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3199 case VOID: break;
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3200 case CHAR: op=COP; type=INT; break;
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3201 case UCHAR: op=COP+US; type=UNSIGNED; break;
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3202 case SHORT: op=SOP; type=SIGNED; break;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3203 case USHORT: op=SOP+US; type=UNSIGNED; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3204 case LONGLONG: op=LOP; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3205 case ULONGLONG: op=LOP+US; break;
333
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3206 case FLOAT: op=FOP; break;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3207 case DOUBLE: op=DOP; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3208 case CODE: return e;
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
3209 case 0: error(-1); return e;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3210 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3211 if (integral(type)) break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3212 switch(car(type)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3213 case ARRAY:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3214 type=list2(POINTER,cadr(type));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3215 if(car(e)==INDIRECT) return cadr(e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3216 return list2(ADDRESS,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3217 case STRUCT: case UNION:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3218 if(car(e)==RSTRUCT) return e; /* ??? */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3219 return list3(RSTRUCT,e,cadr(type) /* size */);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3220 case FUNCTION:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3221 type=cadr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3222 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3223 case CODE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3224 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3225 case POINTER:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3226 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3227 case BIT_FIELD:
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3228 e = list3(RBIT_FIELD,cadr(e),type);
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
3229 /* byte rvalue, store type */
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
3230 type = cadr(type); /* value type */
335
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
3231 return e;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3232 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3233 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3234 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3235 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3236 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3237 switch(car(e)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3238 case GVAR:
445
kono
parents: 444
diff changeset
3239 n = (NMTBL*)caddr(e);
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
3240 if (cadr(e)==0 && (c=attr_value(n,KONST))) {
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
3241 return c;
445
kono
parents: 444
diff changeset
3242 }
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3243 return(list3(RGVAR+op,cadr(e),caddr(e)));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3244 case LVAR:
445
kono
parents: 444
diff changeset
3245 n = (NMTBL*)caddr(e);
453
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
3246 if (n && (c=attr_value(n,KONST))) {
1e5ca85d3f97 inline on going...
kono
parents: 452
diff changeset
3247 return c;
445
kono
parents: 444
diff changeset
3248 }
kono
parents: 444
diff changeset
3249 return(list3(RLVAR+op,cadr(e),caddr(e)));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3250 case INDIRECT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3251 return(indirect(RINDIRECT+op,cadr(e)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3252 default:return(e); /* idempotent case? */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3253 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3254 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3255
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3256 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3257 rvalue_t(int e,int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3258 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3259 int stype = type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3260 type = t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3261 e = rvalue(e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3262 type = stype;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3263 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3264 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3265
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3266 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3267 lcheck(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3268 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3269 int t;
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3270 if(scalar(type)) return;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3271 switch(type) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3272 case DOUBLE: case FLOAT : case LONGLONG: case ULONGLONG:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3273 return;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3274 default:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3275 switch(car(e)) {
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3276 case GVAR: case LVAR: case INDIRECT :
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3277 case REGISTER : case DREGISTER : case FREGISTER : case LREGISTER:
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3278 return;
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3279 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3280 }
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3281 if ((t=car(type))<0 && t!=STRUCT && t!=UNION)
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3282 error(LVERR);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3283 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3284
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3285 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3286 indop(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3287 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3288 if(type!=INT&&type!=UNSIGNED) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3289 if(car(type)==POINTER)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3290 type=cadr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3291 else if(car(type)==CODE || car(type)==FUNCTION)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3292 type=type;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3293 else error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3294 } else
342
3e0b1183983d else if to switch
kono
parents: 341
diff changeset
3295 type= CHAR; // ?!
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3296 if(car(e)==ADDRESS)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3297 return(cadr(e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3298 return(list2(INDIRECT,e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3299 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3300
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3301 /* filed name search */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3302
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3303 /* type = list4(s,disp,fields,tag_nptr); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3304
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3305 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3306 search_struct_type(int type,char *name,int *dsp)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3307 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3308 int t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3309 NMTBL *nptr0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3310 t = caddr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3311 if (t==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3312 nptr0=(NMTBL*)cadddr(type);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3313 t = caddr(type) = caddr(nptr0->ty);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3314 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3315 for(;t;t = cadr(t)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3316 if (neqname((char *)caddr(t),name)==0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3317 *dsp = cadddr(t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3318 return car(t);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3319 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3320 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3321 return 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3322 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3323
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3324 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3325 strop(int e,int ind)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3326 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3327 int dsp = 0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3328
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3329 if (ind) e = indop(rvalue(e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3330 if (integral(type)||(car(type)!=STRUCT && car(type)!=UNION))
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3331 e=rvalue(e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3332 /* type = list4(s,disp,fields,tag_nptr); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3333 /* print_fields(caddr(type),"strop"); */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3334 type = search_struct_type(type,nptr->nm,&dsp);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3335 if (!type) { error(TYERR); type=INT; return e; }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3336 if(dsp) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3337 switch(car(e)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3338 case GVAR:
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3339 // e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3340 e=list3(GVAR,cadr(e)+dsp,caddr(e));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3341 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3342 case LVAR:
445
kono
parents: 444
diff changeset
3343 e=list3(LVAR,cadr(e) + dsp,0); /* may have attribute */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3344 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3345 case INDIRECT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3346 e=list2(INDIRECT,list3(ADD,cadr(e),list2(CONST,dsp)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3347 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3348 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3349 e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3350 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3351 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3352 switch(car(e)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3353 case GVAR: case LVAR: case INDIRECT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3354 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3355 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3356 e=list2(INDIRECT,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3357 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3358 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3359 if (type>0&&car(type)==BIT_FIELD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3360 // n->ty = list4(BIT_FIELD,type,bit_offset, bit_size);
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 419
diff changeset
3361 e=list3(BIT_FIELD,e,type); // ???
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3362 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3363 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3364 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3365
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3366 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3367 /* binary floating computation */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3368
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3369 #define DTYPE(dop) (dop==DOP?DOUBLE:FLOAT)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3370
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3371 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3372 fdbinop(int op, int e1, int e2, int t1, int t2, int dop)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3373 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3374 double d1,d2,d;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3375 int b=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3376
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3377 if (dop==DOP) {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
3378 type=t1; e1=double_value(e1);
dc81596066df type fix done.
kono
parents: 333
diff changeset
3379 type=t2; e2=double_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3380 } else {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
3381 type=t1; e1=float_value(e1);
dc81596066df type fix done.
kono
parents: 333
diff changeset
3382 type=t2; e2=float_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3383 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3384 if(car(e1)==dop+CONST&&car(e2)==dop+CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3385 d1=dcadr(e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3386 d2=dcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3387 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3388 case ADD: d=d1+d2; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3389 case SUB: d=d1-d2; break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3390 case MUL: d=d1*d2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3391 case DIV:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3392 if(!d2) error(EXERR);d=d1/d2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3393 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3394 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3395 case GT: b=(d1>d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3396 case GE: b=(d1>=d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3397 case LT: b=(d1<d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3398 case LE: b=(d1<=d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3399 case EQ: b=(d1==d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3400 case NEQ: b=(d1!=d2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3401 default: error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3402 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3403 type = INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3404 return list2(CONST,b);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3405 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3406 return dlist2(dop+CONST,d);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3407 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3408 if(car(e1)==dop+CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3409 if ((op==SUB||op==ADD)&&dcadr(e1)==0.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3410 return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3411 } else if (op==MUL&&dcadr(e1)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3412 return e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3413 } else if (op==MUL&&-dcadr(e1)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3414 return list2(dop+MINUS,e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3415 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3416 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3417 if(car(e2)==dop+CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3418 if ((op==SUB||op==ADD)&&dcadr(e2)==0.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3419 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3420 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3421 if ((op==DIV||op==MUL)&&dcadr(e2)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3422 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3423 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3424 if ((op==DIV||op==MUL)&&-dcadr(e2)==1.0) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3425 return list2(DMINUS,e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3426 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3427 if (op==SUB) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3428 op=ADD; dcadr(e2) = -dcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3429 } else if(op==DIV) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3430 if(dcadr(e2)==0.0) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3431 op=MUL; dcadr(e2)=1/dcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3432 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3433 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3434 if ((op==ADD||op==MUL) && (
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3435 car(e1)==dop+CONST ||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3436 car(e2)==DRLVAR || car(e2)==DRGVAR ||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3437 car(e2)==FRLVAR || car(e2)==FRGVAR
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3438 )) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3439 return(list3(op+dop,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3440 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3441 if(op==LT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3442 type=INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3443 return(list3(GT+dop,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3444 } else if(op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3445 type=INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3446 return(list3(GE+dop,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3447 } else if(op==GT||op==GE||op==EQ||op==NEQ) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3448 type=INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3449 return(list3(op+dop,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3450 } else if(op==ADD||op==SUB||op==MUL||op==DIV)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3451 return(list3(op+dop,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3452 else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3453 error(-1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3454 return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3455 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3456 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3457
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3458 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3459 dbinop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3460 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3461 return fdbinop(op, e1, e2, t1, t2,DOP);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3462 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3463
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3464 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3465 fbinop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3466 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3467 return fdbinop(op, e1, e2, t1, t2,FOP);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3468 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3469
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3470 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3471
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3472 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3473
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3474 static int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3475 lbinop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3476 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3477 int e=0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3478 long long le1, le2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3479 long long le = 0;
436
kono
parents: 435
diff changeset
3480 int us = ((t1==ULONGLONG||t1==UNSIGNED)&&(t2==ULONGLONG||t2==UNSIGNED));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3481
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3482 if (us||(t1==ULONGLONG&&(op==LSHIFT||op==RSHIFT))) {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
3483 type=t1; e1=ulonglong_value(e1);
dc81596066df type fix done.
kono
parents: 333
diff changeset
3484 type=t2; e2=ulonglong_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3485 } else {
334
dc81596066df type fix done.
kono
parents: 333
diff changeset
3486 type=t1; e1=longlong_value(e1);
dc81596066df type fix done.
kono
parents: 333
diff changeset
3487 type=t2; e2=longlong_value(e2);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3488 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3489 if(car(e1)==LCONST&&car(e2)==LCONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3490 le1=lcadr(e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3491 le2=lcadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3492 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3493 case BOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3494 le=le1|le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3495 case EOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3496 le=le1^le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3497 case BAND:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3498 le=le1&le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3499 case ADD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3500 le=le1+le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3501 case SUB:
436
kono
parents: 435
diff changeset
3502 le=le1-le2; type=LONGLONG; break;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3503 case MUL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3504 le=le1*le2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3505 case DIV:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3506 if(!le2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3507 if (us) le=(((unsigned long long )le1)/((unsigned long long )le2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3508 else e=(le1/le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3509 case MOD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3510 if(!le2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3511 if (us) le=(((unsigned long long )le1)%((unsigned long long )le2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3512 else e=(le1%le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3513 case RSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3514 if (t1==ULONGLONG) le=(((unsigned long long)le1)<<le2); else le=le1<<le2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3515 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3516 case LSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3517 if (t1==ULONGLONG) le=(((unsigned long long)le1)>>le2); else le=le1>>le2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3518 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3519 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3520 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3521 case EQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3522 e=(le1==le2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3523 case NEQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3524 e=(le1!=le2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3525 case LT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3526 le=le1;le1=le2;le2=le;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3527 case GT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3528 if (us) e=((unsigned long long)le1>(unsigned long long)le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3529 else e=(le1>le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3530 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3531 case LE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3532 le=le1;le1=le2;le2=le;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3533 case GE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3534 if (us) e=((unsigned long long)le1>=(unsigned long long)le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3535 else e=(le1>=le2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3536 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3537 default:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3538 error(-1); return list2(CONST,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3539 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3540 type = INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3541 return list2(CONST,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3542 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3543 return llist2(LCONST,le);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3544 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3545 if(op==LT) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3546 type = INT; return(list3(GT+LOP+us,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3547 } else if(op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3548 type = INT; return(list3(GE+LOP+us,e2,e1));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3549 } else if(op==GT||op==GE||op==LT||op==LE) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3550 type = INT; return(list3(op+LOP+us,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3551 }
436
kono
parents: 435
diff changeset
3552 if(op==SUB) { us = 0; type=LONGLONG; }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3553 if(op==SUB&&car(e2)==LCONST) { op=ADD; lcadr(e2)=-lcadr(e2); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3554 if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3555 (car(e1)!=LCONST) && (
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3556 car(e2)==LRGVAR||car(e2)==LRLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3557 car(e2)==LURGVAR||car(e2)==LURLVAR
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3558 )) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3559 e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3560 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3561 if((op==MUL||op==DIV)&&car(e2)==LCONST&&lcadr(e2)==1) return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3562 if(op==BOR||op==EOR||op==BAND||op==ADD||op==SUB||op==EQ||op==NEQ)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3563 return(list3(op+LOP,e1,e2));
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 434
diff changeset
3564 if(op==LSHIFT && car(e2)==LCONST) {
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 434
diff changeset
3565 if (lcadr(e2)==0) return e1;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 434
diff changeset
3566 else if (lcadr(e2)>63) return llist2(LCONST,0);
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 434
diff changeset
3567 }
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 434
diff changeset
3568 if(op==RSHIFT && car(e2)==LCONST) {
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 434
diff changeset
3569 if (lcadr(e2)==0) return e1;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 434
diff changeset
3570 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3571 if(op==LSHIFT||op==RSHIFT) return(list3(op+LOP+(t1==ULONGLONG),e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3572 return(list3(op+LOP+us,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3573 }
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
3574 #endif
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 316
diff changeset
3575
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3576 /* binary integer computation */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3577
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3578 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3579 binop(int op, int e1, int e2, int t1, int t2)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3580 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3581 int e=0;
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3582 int us = 0;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3583
445
kono
parents: 444
diff changeset
3584 if(t1>0&&car(t1)==POINTER) {
kono
parents: 444
diff changeset
3585 if(!(op==SUB && t2>0&&car(t2)==POINTER)) {
kono
parents: 444
diff changeset
3586 type = t2; e2= int_value(e2); t2=INT;
kono
parents: 444
diff changeset
3587 }
kono
parents: 444
diff changeset
3588 } else if(t2>0&&car(t2)==POINTER) {
kono
parents: 444
diff changeset
3589 type = t1; e1= int_value(e1); t1=INT;
kono
parents: 444
diff changeset
3590 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3591 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3592 else if(t1==DOUBLE||t2==DOUBLE)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3593 return dbinop(op,e1,e2,t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3594 else if(t1==FLOAT||t2==FLOAT)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3595 return fbinop(op,e1,e2,t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3596 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3597 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3598 else if(t1==LONGLONG||t2==LONGLONG||t1==ULONGLONG||t2==ULONGLONG)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3599 return lbinop(op,e1,e2,t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3600 #endif
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3601 if (t1==UNSIGNED) {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3602 if (t2==UNSIGNED || (car(e2)==CONST && cadr(e2)>0)) us = 1;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3603 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3604 if (t2==UNSIGNED) {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3605 if (t1==UNSIGNED || (car(e1)==CONST && cadr(e1)>0)) us = 1;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3606 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 350
diff changeset
3607
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3608 if(car(e1)==CONST&&car(e2)==CONST) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3609 e1=cadr(e1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3610 e2=cadr(e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3611 type= INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3612 switch(op) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3613 case BOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3614 e=e1|e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3615 case EOR:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3616 e=e1^e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3617 case BAND:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3618 e=e1&e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3619 case ADD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3620 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3621 if(integral(t2)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3622 e=e1+e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3623 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3624 if(car(t2)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3625 e=size(cadr(t2))*e1+e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3626 type=t2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3627 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3628 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3629 if(car(t1)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3630 e=e1+size(cadr(t1))*e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3631 type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3632 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3633 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3634 case SUB:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3635 if(integral(t1)) {
436
kono
parents: 435
diff changeset
3636 e=e1-e2; type=INT;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3637 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3638 if(car(t1)!=POINTER) error(TYERR);
445
kono
parents: 444
diff changeset
3639 if(integral(t2)) {
kono
parents: 444
diff changeset
3640 e=e1-size(cadr(t1))*e2;
kono
parents: 444
diff changeset
3641 type=t1;
kono
parents: 444
diff changeset
3642 } else {
kono
parents: 444
diff changeset
3643 e=(e1-e2)/size(cadr(t1));
kono
parents: 444
diff changeset
3644 type=INT;
kono
parents: 444
diff changeset
3645 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3646 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3647 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3648 case MUL:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3649 e=e1*e2;break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3650 case DIV:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3651 if(!e2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3652 if (us) e=(((unsigned)e1)/((unsigned)e2)); else e=e1/e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3653 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3654 case MOD:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3655 if(!e2) error(EXERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3656 if (us) e=(((unsigned)e1)%((unsigned)e2)); else e=e1%e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3657 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3658 case RSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3659 if (t1==UNSIGNED) e=(((unsigned)e1)>>((unsigned)e2)); else e=e1>>e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3660 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3661 case LSHIFT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3662 if (t1==UNSIGNED) e=(((unsigned)e1)<<((unsigned)e2)); else e=e1<<e2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3663 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3664 case EQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3665 e=(e1==e2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3666 case NEQ:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3667 e=(e1!=e2);break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3668 case LT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3669 e=e1;e1=e2;e2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3670 case GT:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3671 if (us) e=(((unsigned)e1)>((unsigned)e2)); else e=(e1>e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3672 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3673 case LE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3674 e=e1;e1=e2;e2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3675 case GE:
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3676 if (us) e=(((unsigned)e1)>=((unsigned)e2)); else e=(e1>=e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3677 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3678 default: error(-1); return list2(CONST,0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3679 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3680 return list2(CONST,e);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3681 }
441
1edaa643458e *** empty log message ***
kono
parents: 440
diff changeset
3682 if(op==GT||op==GE||op==LT||op==LE) {
1edaa643458e *** empty log message ***
kono
parents: 440
diff changeset
3683 return(car(e1)==CONST?list3(rop_dual(op)+us,e2,e1):list3(op+us,e1,e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3684 } else if(op==EQ||op==NEQ) {
441
1edaa643458e *** empty log message ***
kono
parents: 440
diff changeset
3685 return(car(e1)==CONST?list3(op,e2,e1):list3(op,e1,e2));
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3686 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3687 if(op==SUB&&car(e2)==CONST) { op=ADD; cadr(e2)=-cadr(e2); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3688 if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3689 (car(e1)!=CONST&& (
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3690 car(e2)==RGVAR||car(e2)==RLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3691 car(e2)==URGVAR||car(e2)==URLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3692 car(e2)==SRGVAR||car(e2)==SRLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3693 car(e2)==SURGVAR||car(e2)==SURLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3694 car(e2)==CRGVAR||car(e2)==CRLVAR||
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3695 car(e2)==CURGVAR||car(e2)==CURLVAR
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3696 ))) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3697 e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3698 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3699 if(op==ADD) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3700 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3701 if(integral(t2)) {
442
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
3702 // if(t1==INT) type=t2;else type=t1;
86b04fb4562e minor fix...
kono
parents: 441
diff changeset
3703 if (us) type=UNSIGNED; else type=INT;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3704 return(list3(ADD,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3705 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3706 if(car(t2)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3707 e=binop(MUL,e1,list2(CONST,size(cadr(t2))),t1,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3708 type=t2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3709 return(list3(ADD,e,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3710 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3711 if(car(t1)!=POINTER||!integral(t2)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3712 e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3713 type=t1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3714 if (car(e)==CONST && cadr(e)==0)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3715 return(e1);
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3716 if (car(e)==CONST) {
444
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
3717 if(car(e1)==ADDRESS) {
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
3718 if (car(cadr(e1))!=GVAR) {
445
kono
parents: 444
diff changeset
3719 // must be lvar
kono
parents: 444
diff changeset
3720 if (car(cadr(e1))!=LVAR) error(-1);
444
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
3721 return(list2(ADDRESS,
445
kono
parents: 444
diff changeset
3722 list3(car(cadr(e1)),cadr(cadr(e1))+cadr(e),
kono
parents: 444
diff changeset
3723 caddr(cadr(e1)))));
444
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
3724 } else {
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
3725 return(list2(ADDRESS,
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
3726 list3(GVAR,cadr(cadr(e1))+cadr(e),caddr(cadr(e1)))));
8bec605d1701 small sized struct
kono
parents: 442
diff changeset
3727 }
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3728 } else if(car(e1)==GVAR) {
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3729 return(list3(GVAR,cadr(e1)+cadr(e),caddr(e1)));
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3730 } else if(car(e1)==LVAR) {
445
kono
parents: 444
diff changeset
3731 return(list3(LVAR,cadr(e1)+cadr(e),0));
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3732 }
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3733 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3734 return(list3(ADD,e1,e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3735 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3736 if(op==SUB) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3737 if(integral(t1)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3738 if(!integral(t2)) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3739 if(t1==INT) type=t2;else type=t1;
436
kono
parents: 435
diff changeset
3740 if (type==UNSIGNED) type=INT;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3741 return(list3(SUB,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3742 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3743 if(car(t1)!=POINTER) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3744 if(integral(t2)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3745 e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3746 type=t1;
367
4efbb07f556b global variable offset
kono
parents: 366
diff changeset
3747 if (car(e)==CONST) error(-1);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3748 return(list3(SUB,e1,e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3749 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3750 if(car(t2)!=POINTER)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3751 error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3752 compatible(t1,t2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3753 e=list3(SUB,e1,e2);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3754 e=binop(DIV,e,list2(CONST,size(cadr(t1))),UNSIGNED,INT);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3755 type= INT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3756 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3757 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3758 if(!integral(t1)||!integral(t2)) error(TYERR);
436
kono
parents: 435
diff changeset
3759 // if(t1==INT) type=t2; else type=t1; /* ??? */
kono
parents: 435
diff changeset
3760 if (us) type=UNSIGNED; else type=INT;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3761 if((op==MUL||op==DIV)&&car(e2)==CONST&&cadr(e2)==1) return e1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3762 if(op==BOR||op==EOR||op==BAND) return(list3(op,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3763 if(op==LSHIFT||op==RSHIFT) return(list3(op+(t1==UNSIGNED?US:0),e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3764 // which ops remain?
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3765 return(list3(op+us,e1,e2));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3766 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3767
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3768 /* coarse for function/code segments arguments */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3769
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3770 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3771 correct_type(int e,int t)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3772 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3773 /* e = rvalue(e); */
333
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3774 #if BIT_FIELD_CODE
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3775 if (type==BIT_FIELD) e = rvalue(e);
bd3e6eff7d41 before *_value type / rvalue type inconsistency fix
kono
parents: 332
diff changeset
3776 #endif
446
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3777 if (t==DOTS) {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3778 if (type==FLOAT) t=DOUBLE;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3779 else if (type==CHAR) t=INT;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3780 else if (type==UCHAR) t=UNSIGNED;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3781 }
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3782 if (type>0 && car(type)==ARRAY && car(e)==GVAR) {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3783 e=list2(ADDRESS,e);
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3784 }
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3785 if (t>0) {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3786 switch(car(t)) {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3787 case STRUCT: case UNION:
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3788 if(size(t)!=size(type)) error(TYERR);
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3789 break;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3790 }
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3791 } else {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3792 switch(t) {
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3793 case DOTS: return e;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3794 case UNSIGNED: e = unsigned_value(e); break;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3795 case CHAR: e = char_value(e); t = INT; break;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3796 case UCHAR: e = uchar_value(e); t = UNSIGNED; break;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3797 case SHORT: e = short_value(e); t = INT; break;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3798 case USHORT: e = ushort_value(e); t = UNSIGNED; break;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3799 #if FLOAT_CODE
446
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3800 case FLOAT: e = float_value(e); break;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3801 case DOUBLE: e = double_value(e); break;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3802 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3803 #if LONGLONG_CODE
446
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3804 case LONGLONG: e = longlong_value(e); break;
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3805 case ULONGLONG: e = ulonglong_value(e); break;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3806 #endif
446
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3807 default:
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3808 if (integral(t)) e = int_value(e);
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3809 }
6654aa80851b fix array pointer in decl_data and cast
kono
parents: 445
diff changeset
3810 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3811 type = t;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3812 return e;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3813 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3814
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3815
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3816 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3817 cexpr(int e)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3818 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3819 if (car(e) != CONST) error(CNERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3820 return (cadr(e));
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3821 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3822
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3823 #define is_long_type(type) (type==LONGLONG||type==ULONGLONG)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3824
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3825 #if BIT_FIELD_CODE
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3826
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3827 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3828 bitfield struct { char a:1; unsigned int b:10; }
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3829 System dependent bit alignment is defined by code_bit_field_disp.
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3830 type of bitfield represents type of the value
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3831 these values are stored in a stored type which can be different from
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3832 value type.
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3833 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3834
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3835 static int
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3836 bit_field(int e1,int t)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3837 {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3838 int reg;
332
ce85d6106119 bit field continue. (code generation done)
kono
parents: 331
diff changeset
3839 if (car(e1)==BIT_FIELD) {
ce85d6106119 bit field continue. (code generation done)
kono
parents: 331
diff changeset
3840 printf("# bit_field_bug\n");
ce85d6106119 bit field continue. (code generation done)
kono
parents: 331
diff changeset
3841 e1 = cadr(e1);
ce85d6106119 bit field continue. (code generation done)
kono
parents: 331
diff changeset
3842 }
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3843 g_expr(e1);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3844 emit_push();
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3845 code_bit_field(t, reg = emit_pop(0), USE_CREG);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3846 emit_pop_free(reg);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3847 return cadr(t); /* value type */
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3848 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3849
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3850 static int
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3851 bit_field_repl(int e1,int e2,int t)
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3852 {
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
3853 /* e1 = e2 */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
3854 if ((car(e2)==CONST||car(e2)==LCONST)) {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
3855 g_expr(e1);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3856 code_bit_replace_const(e2,USE_CREG,t);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3857 return t;
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 363
diff changeset
3858 }
335
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
3859 g_expr(e1);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3860 emit_push();
335
4f98dc4b5fd8 bit-field continue... code-generation debug
kono
parents: 334
diff changeset
3861 g_expr(e2);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3862 code_bit_replace(e2=emit_pop(0),USE_CREG,t);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3863 emit_pop_free(e2);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3864 return t;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3865 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3866
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3867 static int
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3868 bassign(int e2,int e3,int t)
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3869 {
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3870 int type = cadr(t);
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3871 /* e2 = e3 */
339
375d21a2b845 emit_data
kono
parents: 338
diff changeset
3872 if (car(e2)==BIT_FIELD) {
375d21a2b845 emit_data
kono
parents: 338
diff changeset
3873 e2 = cadr(e2);
375d21a2b845 emit_data
kono
parents: 338
diff changeset
3874 }
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3875 bit_field_repl(e2,e3,t);
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3876 return type;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3877 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3878
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3879 static int
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3880 bassop(int e2,int e3,int op,int t,int post)
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3881 {
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3882 /*
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3883 n = bit_field address
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3884 code_bit_field
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3885 if (post) n1 = value
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3886 value op= operand
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3887 n bit-repl value
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3888 if (post) n1;
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3889 */
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3890 /* e2 = e2 op e3; */
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3891 /* new = &e2 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3892 /* *new = *new op e3 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3893 int suse = use;
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3894 int lo = (type==LONGLONG||type==ULONGLONG);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3895 int n1=0,n2=0;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3896 int reg;
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3897
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3898 g_expr(list2(ADDRESS,cadr(e2)));
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3899 reg = emit_push();
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3900 code_bit_field(t, reg, USE_CREG);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3901 use=1;
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3902 if (lo) {
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
3903 #if LONGLONG_CODE
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3904 if (post) {
445
kono
parents: 444
diff changeset
3905 n1 = list3(LVAR,new_lvar(size_of_longlong),0);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3906 code_lassign_lvar(cadr(n1),USE_CREG);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3907 }
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3908 if (!code_lassop_p) {
445
kono
parents: 444
diff changeset
3909 n2 = list3(LVAR,new_lvar(size_of_longlong),0);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3910 code_lassign_lvar(cadr(n2),USE_CREG);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3911 lassign(list4(LASSOP,n2,e3,op+LOP));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3912 } else {
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3913 emit_lpush();
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3914 g_expr(e3);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3915 code_register_lassop(USE_CREG,op+LOP);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3916 }
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
3917 #else
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
3918 error(TYERR);
a531bbf572e3 regression test (case, float, long long)
kono
parents: 439
diff changeset
3919 #endif
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3920 } else {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3921 if (post) {
445
kono
parents: 444
diff changeset
3922 n1 = list3(LVAR,new_lvar(size_of_int),0);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3923 code_assign_lvar(cadr(n1),USE_CREG,0);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3924 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3925 emit_push();
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3926 g_expr(e3);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3927 code_register_assop((e2=emit_pop(0)),USE_CREG,op,size(type));
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3928 if (use) {
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3929 code_register(e2,USE_CREG);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3930 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3931 emit_pop_free(e2);
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3932 }
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3933 use=post?0:suse;
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3934 code_bit_replace(e2=emit_pop(0),USE_CREG,t);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3935 emit_pop_free(e2);
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
3936 use = suse;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3937 if (post&&use) { g_expr(rvalue_t(n1,type));}
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3938 if (n1) free_lvar(cadr(n1));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3939 if (n2) free_lvar(cadr(n2));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 426
diff changeset
3940
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
3941 return type;
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3942 }
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3943
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3944 #endif
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
3945
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3946 /* temporal local variable free list */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3947
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3948 static int lvar_list,lvar_free_list;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3949
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3950 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3951 new_lvar0(int sz)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3952 {
397
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
3953 switch (disp_align) {
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
3954 default:
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
3955 case 0: return disp-=sz;
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
3956 case 4:
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
3957 disp-=sz;
409
b72682778d75 ARM varargs
kono
parents: 397
diff changeset
3958 if (sz>=4) disp &= -4;
397
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
3959 return disp;
33a09aa401ba arm const pass
kono
parents: 388
diff changeset
3960 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3961 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3962
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3963 extern int
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3964 new_lvar(int size)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3965 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3966 int lvar,plvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3967
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3968 for (plvar = 0,lvar = lvar_free_list;lvar;lvar = cadr(lvar)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3969 if (caddr(lvar)==size) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3970 if (plvar) cadr(plvar) = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3971 else lvar_free_list = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3972 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3973 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3974 plvar = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3975 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3976 if (!lvar) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3977 lvar_list = glist3((lvar=new_lvar0(size)),lvar_list,size);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3978 } else {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3979 cadr(lvar) = lvar_list; lvar_list = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3980 lvar = car(lvar_list);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3981 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3982 return lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3983 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3984
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3985 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3986 free_lvar(int disp)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3987 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3988 int lvar,plvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3989
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3990 for (plvar = 0,lvar = lvar_list;lvar;lvar = cadr(lvar)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3991 if (car(lvar)==disp) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3992 if (plvar) cadr(plvar) = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3993 else lvar_list = cadr(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3994 break;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3995 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3996 plvar = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3997 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3998 if (!lvar) error(-1);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3999 cadr(lvar) = lvar_free_list; lvar_free_list = lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4000 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4001
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4002 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4003 init_free_lvar_list()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4004 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4005 int lvar;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4006 while((lvar=lvar_list)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4007 lvar_list=cadr(lvar_list);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4008 free_glist3(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4009 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4010 while((lvar=lvar_free_list)) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4011 lvar_free_list=cadr(lvar_free_list);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4012 free_glist3(lvar);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4013 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4014 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4015
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4016 extern void
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
4017 gen_comment(char *s)
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
4018 {
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
4019 if (!chk)
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
4020 code_comment(s);
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
4021 }
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
4022
b8f95294eb77 inline continue... if test passed.
kono
parents: 455
diff changeset
4023 extern void
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4024 gen_code_enter(char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4025 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4026 code_enter(name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4027 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4028
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4029 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4030 gen_code_enter1(int args)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4031 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4032 code_enter1(args);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4033 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4034
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4035 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4036 gen_code_leave(char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4037 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4038 code_leave(name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4039 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4040
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4041 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4042 gen_enter(char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4043 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4044 enter(name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4045 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4046
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4047 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4048 gen_enter1()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4049 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4050 enter1();
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4051 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4052
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4053 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4054 gen_leave(int control, char *name)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4055 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4056 leave(control,name);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4057 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4058
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4059 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4060 gen_jmp(int l)
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4061 {
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
4062 control=0;
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
4063 if (!pending_jmp) {
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
4064 pending_jmp = l;
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 437
diff changeset
4065 }
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4066 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4067
363
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
4068 extern void
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
4069 gen_indirect_goto(int e1)
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
4070 {
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
4071 g_expr(e1);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
4072 code_indirect_jmp(USE_CREG);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
4073 }
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
4074
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4075 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4076 make bit mask
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4077 MSB 1 2 3 4 .... 29 30 31 LSB
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4078 */
336
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4079 extern int
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4080 make_mask(int from,int to)
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4081 {
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4082 int mask = 0;
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4083 int bit = 1;
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4084 int i;
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4085 if (from<0||from>32) error(-1);
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4086 for (i=31;from<=i;i--,bit<<=1) {
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4087 if (i<=to) {
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4088 mask |= bit;
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4089 }
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4090 }
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4091 return mask;
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4092 }
d488b72254fb bit-field done.
kono
parents: 335
diff changeset
4093
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4094 #define MAX_PTR_CACHE 10
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4095
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4096 static int ptr_cache=0;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4097 static int ptr_cache_last=0;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4098
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4099 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4100 global name pointer cache
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4101 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4102
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4103 extern void
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4104 init_ptr_cache()
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4105 {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4106 int i;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4107 for(i=0;i<MAX_PTR_CACHE-1;i++) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4108 ptr_cache=glist3(0,ptr_cache,0);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4109 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4110 ptr_cache_last=ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4111 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4112
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4113 extern void
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4114 clear_ptr_cache_reg(int r)
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4115 {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4116 int ptcptr=ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4117 int prev = 0;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4118 while(ptcptr!=ptr_cache_last) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4119 if(car(ptcptr)&&caddr(ptcptr)==r) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4120 free_register(r); caddr(ptcptr)=-1; car(ptcptr)=0;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4121 // remove me
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4122 if (prev) cadr(prev) = cadr(ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4123 else ptr_cache = cadr(ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4124 // add me to the next of ptr_cache_last
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4125 cadr(ptcptr) = cadr(ptr_cache_last);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4126 cadr(ptr_cache_last) = ptcptr;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4127 return;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4128 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4129 ptcptr=cadr(prev=ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4130 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4131 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4132
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4133 extern int
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4134 last_ptr_cache()
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4135 {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4136 int ptcptr=ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4137 int r = 0;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4138 while(ptcptr!=ptr_cache_last) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4139 r = caddr(ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4140 ptcptr=cadr(ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4141 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4142 return r;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4143 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4144
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4145
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4146 extern void
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4147 clear_ptr_cache()
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4148 {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4149 int ptcptr=ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4150 while(ptcptr!=ptr_cache_last) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4151 free_register(caddr(ptcptr)); caddr(ptcptr)=-1; car(ptcptr)=0;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4152 ptcptr=cadr(ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4153 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4154 ptr_cache_last = ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4155 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4156
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4157
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4158 extern int
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4159 get_ptr_cache(NMTBL *nptr)
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4160 {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4161 int r;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4162 int ptcptr=ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4163 int g = (int)nptr;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4164 int prev=0,p;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4165
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4166 // linear search cache
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4167 while(ptcptr!=ptr_cache_last) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4168 if(car(ptcptr)==g) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4169 if (prev) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4170 // make this top
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4171 cadr(prev)=cadr(ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4172 cadr(ptcptr) = ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4173 ptr_cache = ptcptr;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4174 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4175 return caddr(ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4176 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4177 ptcptr=cadr(prev=ptcptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4178 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4179 if (!cadr(ptr_cache_last)) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4180 // cache is full
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4181 if (prev) {
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4182 // remove oldest cache and it becomes the last
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4183 free_register(caddr(prev)); caddr(ptcptr)=-1; car(ptcptr)=0;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4184 ptr_cache_last = prev;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4185 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4186 else error(-1);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4187 }
430
ba5faa547607 ARM bitfield done.
kono
parents: 427
diff changeset
4188 r = get_register(0); // some ptr cache may remove by this
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4189 caddr(p = cadr(ptr_cache_last)) = r;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4190 car(p) = g;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4191 use_ptr_cache(r);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4192
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4193 cadr(ptr_cache_last) = cadr(p);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4194 cadr(p) = ptr_cache;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4195 ptr_cache = p;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4196 code_ptr_cache_def(r,nptr);
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4197 return r;
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4198 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4199
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4200 extern int
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4201 ilog(int i)
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4202 {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 424
diff changeset
4203 /* number of bit (i-1) is better? */
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4204 switch(i) {
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4205 case 2: return 1;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4206 case 4: return 2;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4207 case 8: return 3;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4208 case 16: return 4;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4209 case 32: return 5;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4210 case 64: return 6;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4211 case 128: return 7;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4212 case 256: return 8;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4213 case 512: return 9;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4214 case 1024: return 10;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4215 case 2048: return 11;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4216 case 4096: return 12;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4217 case 8192: return 13;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4218 case 16384: return 14;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4219 case 32768: return 15;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4220 case 65536: return 16;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4221 case 131072: return 17;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4222 case 262144: return 18;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4223 case 524288: return 19;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4224 }
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4225 return 0;
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
4226 }
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
4227
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
4228 /* end */