annotate mc-codegen.c @ 487:b4d9809d6ee2

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