annotate mc-inline.c @ 928:96c53f76b360

fix
author kono
date Sun, 13 Apr 2014 10:21:40 +0900
parents 8bdd5061cb8f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
kono
parents:
diff changeset
1 /* Micro-C Partial Evaluator Part */
kono
parents:
diff changeset
2
607
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
3 /************************************************************************
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
4 ** Copyright (C) 2006 Shinji Kono
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
5 ** 連絡先: 琉球大学情報工学科 河野 真治
795
a4fd2ab28e24 i64 va_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
6 *)* (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
607
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
7 **
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
8 ** このソースのいかなる複写,改変,修正も許諾します。ただし、
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
9 ** その際には、誰が貢献したを示すこの部分を残すこと。
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
10 ** 再配布や雑誌の付録などの問い合わせも必要ありません。
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
11 ** 営利利用も上記に反しない範囲で許可します。
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
12 ** バイナリの配布の際にはversion messageを保存することを条件とします。
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
13 ** このプログラムについては特に何の保証もしない、悪しからず。
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
14 **
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
15 ** Everyone is permitted to do anything on this program
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
16 ** including copying, modifying, improving,
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
17 ** as long as you don't try to pretend that you wrote it.
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
18 ** i.e., the above copyright notice has to appear in all copies.
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
19 ** Binary distribution requires original version messages.
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
20 ** You don't have to ask before copying, redistribution or publishing.
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
21 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
e055df7c1082 *** empty log message ***
kono
parents: 601
diff changeset
22 ***********************************************************************/
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
23
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
24 /*
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
25
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
26 Inline handler
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
27
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
28 inline code is stored as parse tree
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
29 expr already has parse tree
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
30 statement part is handled here
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
31
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
32 st_hoge() code generator (called from gexpr())
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
33 p_hoge() partial evaluator called in gen_inline()
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
34 after p_hoge(), it contains no ST_* node.
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
35
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
36 PVAR has an offset for pvartable, it can be
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
37 constant, local variable or global variable
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
38 other complex expression is evaluated before the code expansion
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
39
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
40 We always perform inline expansion.
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
41 Non static inline function can be referenced from other. Real
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
42 function body is generated by pfdecl() in mc-parse.c.
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
43
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
44 */
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
45
462
kono
parents:
diff changeset
46 #include <stdio.h>
kono
parents:
diff changeset
47 #include "mc.h"
kono
parents:
diff changeset
48 #include "mc-parse.h"
kono
parents:
diff changeset
49 #include "mc-codegen.h"
kono
parents:
diff changeset
50 #include "mc-switch.h"
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
51 #include "mc-code.h"
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
52 #include "mc-inline.h"
462
kono
parents:
diff changeset
53
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
54 static int pvartable;
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
55 static int pdisp;
462
kono
parents:
diff changeset
56
514
a2047e4555be inline continue....
kono
parents: 513
diff changeset
57 static int ret_register,ret_reg_mode;
a2047e4555be inline continue....
kono
parents: 513
diff changeset
58
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
59 static int inline_lvars;
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
60
462
kono
parents:
diff changeset
61 /*
kono
parents:
diff changeset
62 Basic code generator from parse tree
kono
parents:
diff changeset
63 */
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 extern void
kono
parents:
diff changeset
66 st_decl(int e1){
kono
parents:
diff changeset
67 // NMTBL *n = (NMTBL *)caddr(e1);
kono
parents:
diff changeset
68 // int stmode = cadddr(e1);
kono
parents:
diff changeset
69 }
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 extern void
kono
parents:
diff changeset
72 st_if(int e1){
kono
parents:
diff changeset
73 int l1,l2,slfree;
kono
parents:
diff changeset
74 int e2=caddr(e1),e3;
kono
parents:
diff changeset
75 // conv->if_();
kono
parents:
diff changeset
76 slfree=lfree;
kono
parents:
diff changeset
77 checkret();
kono
parents:
diff changeset
78 l1 = bexpr(car(e2),0,fwdlabel());
kono
parents:
diff changeset
79 // conv->if_then_();
kono
parents:
diff changeset
80 g_expr_u(cadr(e2));
kono
parents:
diff changeset
81 checkret();
kono
parents:
diff changeset
82 if ((e3=caddr(e2))) { // else
kono
parents:
diff changeset
83 // conv->if_else_();
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
84 if ((l2 = control))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
85 gen_jmp(l2=fwdlabel());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
86 fwddef(l1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
87 g_expr_u(e3);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
88 checkret();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
89 if (l2) fwddef(l2);
462
kono
parents:
diff changeset
90 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
91 fwddef(l1);
462
kono
parents:
diff changeset
92 }
kono
parents:
diff changeset
93 // conv->if_endif_();
kono
parents:
diff changeset
94 }
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 extern void
kono
parents:
diff changeset
98 st_do(int e1){
kono
parents:
diff changeset
99 int sbreak,scontinue,l;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 sbreak=blabel;
kono
parents:
diff changeset
102 scontinue=clabel;
kono
parents:
diff changeset
103 blabel=fwdlabel();
kono
parents:
diff changeset
104 clabel=fwdlabel();
kono
parents:
diff changeset
105 control=1;
kono
parents:
diff changeset
106 checkret();
kono
parents:
diff changeset
107 l=backdef();
kono
parents:
diff changeset
108 // conv->dowhile_();
kono
parents:
diff changeset
109 g_expr_u(cadddr(e1));
kono
parents:
diff changeset
110 checkret();
kono
parents:
diff changeset
111 // conv->dowhile_cond_();
kono
parents:
diff changeset
112 bexpr(caddr(e1),1,l);
kono
parents:
diff changeset
113 // conv->dowhile_end_();
kono
parents:
diff changeset
114 fwddef(blabel);
kono
parents:
diff changeset
115 clabel=scontinue;
kono
parents:
diff changeset
116 blabel=sbreak;
kono
parents:
diff changeset
117 }
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 extern void
kono
parents:
diff changeset
121 st_while(int e1){
kono
parents:
diff changeset
122 int sbreak,scontinue,e;
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 sbreak=blabel;
kono
parents:
diff changeset
125 scontinue=clabel;
kono
parents:
diff changeset
126 blabel=fwdlabel();
kono
parents:
diff changeset
127 control=1;
kono
parents:
diff changeset
128 checkret();
kono
parents:
diff changeset
129 clabel=backdef();
kono
parents:
diff changeset
130 // conv->while_();
kono
parents:
diff changeset
131 // conv->while_body_();
kono
parents:
diff changeset
132 if(!(e=cadddr(e1))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
133 bexpr(caddr(e1),1,clabel);
462
kono
parents:
diff changeset
134 // conv->sm_();
kono
parents:
diff changeset
135 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
136 bexpr(caddr(e1),0,blabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
137 g_expr_u(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
138 checkret();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
139 if(control)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
140 gen_jmp(clabel);
462
kono
parents:
diff changeset
141 }
kono
parents:
diff changeset
142 // conv->while_end_();
kono
parents:
diff changeset
143 fwddef(blabel);
kono
parents:
diff changeset
144 clabel=scontinue;
kono
parents:
diff changeset
145 blabel=sbreak;
kono
parents:
diff changeset
146 }
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 extern void
kono
parents:
diff changeset
150 st_for(int e1){
kono
parents:
diff changeset
151 int p0,p1,p2,body;
kono
parents:
diff changeset
152 int l,e;
kono
parents:
diff changeset
153 int sbreak=blabel;
kono
parents:
diff changeset
154 int scontinue=clabel;
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 e = caddr(e1);
kono
parents:
diff changeset
157 p0 = car(e); p1 = cadr(e); p2 = caddr(e); body = cadddr(e);
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 blabel=fwdlabel();
kono
parents:
diff changeset
160 // conv->for_();
kono
parents:
diff changeset
161 if (p0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
162 checkret();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
163 g_expr_u(p0);
462
kono
parents:
diff changeset
164 }
kono
parents:
diff changeset
165 // conv->for1_();
kono
parents:
diff changeset
166 control=1;
kono
parents:
diff changeset
167 checkret();
kono
parents:
diff changeset
168 l=backdef();
kono
parents:
diff changeset
169 if (p1) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
170 bexpr(p1,0,blabel);
462
kono
parents:
diff changeset
171 }
kono
parents:
diff changeset
172 // conv->for2_();
kono
parents:
diff changeset
173 // conv->for_body_();
kono
parents:
diff changeset
174 if (!p2) {
kono
parents:
diff changeset
175 clabel=l;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
176 g_expr_u(body);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
177 checkret();
462
kono
parents:
diff changeset
178 } else {
kono
parents:
diff changeset
179 clabel=fwdlabel();
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
180 g_expr_u(body);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
181 checkret();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
182 fwddef(clabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
183 g_expr_u(p2);
462
kono
parents:
diff changeset
184 }
kono
parents:
diff changeset
185 // conv->for_end_();
kono
parents:
diff changeset
186 gen_jmp(l);
kono
parents:
diff changeset
187 fwddef(blabel);
kono
parents:
diff changeset
188 clabel=scontinue;
kono
parents:
diff changeset
189 blabel=sbreak;
kono
parents:
diff changeset
190 }
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 extern void
kono
parents:
diff changeset
194 st_switch(int e1){
kono
parents:
diff changeset
195 int sbreak,scase,sdefault,slfree,svalue,slist;
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
196 int cst,e;
462
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 checkret();
kono
parents:
diff changeset
199 slist = cslist;
kono
parents:
diff changeset
200 cslist = 0;
kono
parents:
diff changeset
201 sbreak=blabel; /* save parents break label */
kono
parents:
diff changeset
202 blabel=fwdlabel();
kono
parents:
diff changeset
203 sdefault=dlabel; /* save parents default label */
kono
parents:
diff changeset
204 dlabel=0;
kono
parents:
diff changeset
205 scase=cslabel; /* save parents next case label */
kono
parents:
diff changeset
206 // conv->switch_();
kono
parents:
diff changeset
207 slfree=lfree;
kono
parents:
diff changeset
208 svalue=csvalue1; /* save parents switch value */
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
209 e =caddr(e1); /* switch value */
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
210 if (car(e)==CONST) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
211 cst = 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
212 csvalue1=glist2(CONST,cadr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
213 gen_jmp( cslabel=fwdlabel());
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
214 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
215 cst = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
216 g_expr(e); /* switch value */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
217 csvalue1=csvalue() ;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
218 cslabel = control = 0;
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
219 }
462
kono
parents:
diff changeset
220 // conv->switch_body_();
kono
parents:
diff changeset
221 g_expr_u(cadddr(e1));
kono
parents:
diff changeset
222 // conv->switch_end_();
kono
parents:
diff changeset
223 checkret();
kono
parents:
diff changeset
224 #if CASE_CODE
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
225 if (!cst) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
226 if (control) gen_jmp(blabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
227 genswitch(cslist,cslabel);
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
228 } else if (!cslist) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
229 if(dlabel) df_label(cslabel,dlabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
230 else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
231 fwddef(cslabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
232 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
233 cslist= 1;
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
234 }
462
kono
parents:
diff changeset
235 #else
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
236 if (!(cst && cslist)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
237 if(dlabel) df_label(cslabel,dlabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
238 else fwddef(cslabel);
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
239 }
462
kono
parents:
diff changeset
240 #endif
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
241 free_glist2(csvalue1);
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
242 if (cst && !cslist) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
243 if(pending_jmp!=cslabel)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
244 fwddef(cslabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
245 else pending_jmp = 0; // cslabel is here
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
246 }
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
247 fwddef(blabel);
462
kono
parents:
diff changeset
248 csvalue1=svalue;
kono
parents:
diff changeset
249 cslabel=scase;
kono
parents:
diff changeset
250 dlabel=sdefault;
kono
parents:
diff changeset
251 blabel=sbreak;
kono
parents:
diff changeset
252 cslist = slist;
kono
parents:
diff changeset
253 }
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 extern void
kono
parents:
diff changeset
257 st_comp(int e1){
kono
parents:
diff changeset
258 g_expr_u(caddr(e1));
kono
parents:
diff changeset
259 }
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 extern void
kono
parents:
diff changeset
263 st_break(int e1){
kono
parents:
diff changeset
264 checkret();
kono
parents:
diff changeset
265 // conv->break_();
kono
parents:
diff changeset
266 if (control)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
267 gen_jmp(blabel);
462
kono
parents:
diff changeset
268 }
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 extern void
kono
parents:
diff changeset
272 st_continue(int e1){
kono
parents:
diff changeset
273 checkret();
kono
parents:
diff changeset
274 // conv->continue_();
kono
parents:
diff changeset
275 if (control) gen_jmp(clabel);
kono
parents:
diff changeset
276 }
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 extern void
kono
parents:
diff changeset
280 st_case(int e1){
kono
parents:
diff changeset
281 #if CASE_CODE
569
1fcad06b264a gcc4 (ia32)
kono
parents: 566
diff changeset
282 int l=0,clist=caddr(e1),c;
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
283 int cst = (car(csvalue1)==CONST);
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
284 if (cst) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
285 c=cadr(csvalue1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
286 for(;clist;clist=cadr(clist)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
287 if (car(clist)==c) break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
288 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
289 if (!clist) return; // no match
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
290 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
291 l = fwdlabel();
462
kono
parents:
diff changeset
292 if (retpending) {
kono
parents:
diff changeset
293 ret(); retpending=0;
kono
parents:
diff changeset
294 }
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
295 if (cst) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
296 if (cslist) { // may duplicat csvalue
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
297 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
298 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
299 cslist=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
300 fwddef(cslabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
301 return;
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
302 }
462
kono
parents:
diff changeset
303 if (!cslabel) {
kono
parents:
diff changeset
304 if (!control) {
kono
parents:
diff changeset
305 cmpdimm(car(clist),csvalue1,cslabel=fwdlabel(),1);
kono
parents:
diff changeset
306 caddr(clist)=0;
kono
parents:
diff changeset
307 } else {
kono
parents:
diff changeset
308 error(-1);
kono
parents:
diff changeset
309 }
kono
parents:
diff changeset
310 }
kono
parents:
diff changeset
311 while(clist) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
312 caddr(clist) = l;
462
kono
parents:
diff changeset
313 clist = cadr(c=clist); cadr(c) = 0; // insert destroy cadr of clist
kono
parents:
diff changeset
314 cslist=insert_ascend(cslist,c,docase_eq);
kono
parents:
diff changeset
315 }
kono
parents:
diff changeset
316 fwddef(l);
kono
parents:
diff changeset
317 control=1;
kono
parents:
diff changeset
318 #else
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
319 int c,clist,l;
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
320 int cst = (car(csvalue1)==CONST);
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
321 clist = caddr(e1);
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
322 if (cst) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
323 c=cadr(csvalue1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
324 for(;clist;clist=cadr(clist)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
325 if (car(clist)==c) break; // no match
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
326 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
327 if (!clist) return;
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
328 }
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
329 if (cst) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
330 if (!cslist) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
331 if (retpending) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
332 ret(); retpending=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
333 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
334 fwddef(cslabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
335 cslist = 1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
336 } // else error(CSERR);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
337 return;
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
338 }
462
kono
parents:
diff changeset
339 if (retpending) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
340 ret(); retpending=0;
462
kono
parents:
diff changeset
341 }
kono
parents:
diff changeset
342 l=fwdlabel();
kono
parents:
diff changeset
343 if (control) {
kono
parents:
diff changeset
344 control=0;
kono
parents:
diff changeset
345 gen_jmp(l);
kono
parents:
diff changeset
346 }
kono
parents:
diff changeset
347 if (cslabel) fwddef(cslabel);
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
348 while(cadr(clist)) {
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
349 cmpdimm(car(clist),csvalue1,l,0);
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
350 clist=cadr(clist);
462
kono
parents:
diff changeset
351 }
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
352 cmpdimm(car(clist),csvalue1,cslabel=fwdlabel(),1);
462
kono
parents:
diff changeset
353 if (l) fwddef(l);
kono
parents:
diff changeset
354 #endif
kono
parents:
diff changeset
355 }
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 extern void
kono
parents:
diff changeset
359 st_default(int e1){
888
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
360 // int clist=caddr(e1);
558
528fed826f17 const value switch statement prune.
kono
parents: 557
diff changeset
361 // int cst = (car(csvalue1)==CONST);
888
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
362 // if (cst) {
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
363 // int c=cadr(csvalue1);
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
364 // for(;clist;clist=cadr(clist)) {
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
365 // if (car(clist)==c) break;
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
366 // }
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
367 // if (!clist) return; // no match
2466ac7c1287 remove no-controled statement in inline
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 887
diff changeset
368 // }
462
kono
parents:
diff changeset
369 control=1;
kono
parents:
diff changeset
370 checkret();
kono
parents:
diff changeset
371 if (dlabel) error(STERR); // double default:
kono
parents:
diff changeset
372 dlabel = backdef();
kono
parents:
diff changeset
373 }
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 extern void
kono
parents:
diff changeset
377 st_return(int e1){
514
a2047e4555be inline continue....
kono
parents: 513
diff changeset
378 int e,t;
462
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 if (!cslabel) gen_jmp(cslabel = fwdlabel());
kono
parents:
diff changeset
381 if(!(e=caddr(e1))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
382 // no return value
462
kono
parents:
diff changeset
383 retpending = 1;
kono
parents:
diff changeset
384 return;
kono
parents:
diff changeset
385 }
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
386 t = type_value(cadr(fnptr->ty));
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
387 if (t>0 && (car(t)==STRUCT || car(t)==UNION)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
388 // copy is included in e, pass the pointer
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
389 t = list2(POINTER,type_value(cadr(fnptr->ty)));
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
390 }
705
0554b7f985ee parse mode done.
kono
parents: 704
diff changeset
391 if (e) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
392 g_expr(e);
705
0554b7f985ee parse mode done.
kono
parents: 704
diff changeset
393 }
0554b7f985ee parse mode done.
kono
parents: 704
diff changeset
394 if (e && t!=VOID) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
395 if (ret_reg_mode==0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
396 // return value register is not fixed
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
397 ret_reg_mode=1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
398 ret_register = code_get_fixed_creg(USE_CREG,t);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
399 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
400 code_set_fixed_creg(ret_register,1,t);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
401 }
462
kono
parents:
diff changeset
402 }
kono
parents:
diff changeset
403 // conv->return_end_();
kono
parents:
diff changeset
404 retpending = 1;
kono
parents:
diff changeset
405 }
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 extern void
kono
parents:
diff changeset
408 st_goto(int e){
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
409 int e1;
462
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 checkret();
kono
parents:
diff changeset
412 e1 = caddr(e);
kono
parents:
diff changeset
413 if (car(e1)==RINDIRECT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
414 gen_indirect_goto(cadr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
415 return ;
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
416 } else if (car(e1)==RLVAR) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
417 gen_indirect_goto(e1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
418 return ;
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
419 } else if (car(e1)==LVAR||car(e1)==FLABEL) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
420 gen_jmp(cadr(e1));
462
kono
parents:
diff changeset
421 control=0;
505
5d4112735c5c *** empty log message ***
kono
parents: 504
diff changeset
422 return ;
691
25115b50d033 *** empty log message ***
kono
parents: 690
diff changeset
423 } else if (car(e1)==JUMP) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
424 /* CbC continuation */
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
425 // conv->jump_(env);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
426 // should be separate function
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
427 jump(cadr(e1),caddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
428 control=0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
429 // conv->sm_();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
430 return ;
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
431 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
432 error(-1);
462
kono
parents:
diff changeset
433 }
kono
parents:
diff changeset
434 }
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 #if ASM_CODE
kono
parents:
diff changeset
438 extern void
kono
parents:
diff changeset
439 st_asm(int e1){
kono
parents:
diff changeset
440 checkret();
kono
parents:
diff changeset
441 g_expr_u(list3(ASM,caddr(e1),cadddr(e1)));
kono
parents:
diff changeset
442 }
kono
parents:
diff changeset
443 #endif
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445
kono
parents:
diff changeset
446 extern void
kono
parents:
diff changeset
447 st_label(int e1){
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
448 int lb = caddr(e1);
462
kono
parents:
diff changeset
449 control=1;
kono
parents:
diff changeset
450 checkret();
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
451 if (car(lb)==LVAR) { // label variable case
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
452 } else if (car(lb)!=FLABEL) error(-1);
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
453 fwddef(cadr(lb));
462
kono
parents:
diff changeset
454 }
kono
parents:
diff changeset
455
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
456 static
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
457 char *plinebuf; // last comment in parse tree (for compiler debug)
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
458
713
88e364604533 *** empty log message ***
kono
parents: 712
diff changeset
459 static int plineno;
88e364604533 *** empty log message ***
kono
parents: 712
diff changeset
460
462
kono
parents:
diff changeset
461 extern void
kono
parents:
diff changeset
462 st_comment(int e1){
574
aad312f61654 remove too much inmode.
kono
parents: 569
diff changeset
463 glineno++;
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 574
diff changeset
464 printf("## %d ",glineno);
713
88e364604533 *** empty log message ***
kono
parents: 712
diff changeset
465 plineno = caddr(e1);
88e364604533 *** empty log message ***
kono
parents: 712
diff changeset
466 gen_comment(plinebuf=(char *)ncadddr(e1));
462
kono
parents:
diff changeset
467 }
kono
parents:
diff changeset
468
kono
parents:
diff changeset
469 /*
kono
parents:
diff changeset
470 partial evaluator
kono
parents:
diff changeset
471 */
kono
parents:
diff changeset
472
kono
parents:
diff changeset
473 static int
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
474 p_vartable(int adisp,int ldisp)
462
kono
parents:
diff changeset
475 {
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
476 int i;
505
5d4112735c5c *** empty log message ***
kono
parents: 504
diff changeset
477 int pvartable = getfree(adisp-ldisp); // have to be local heap
509
e58848f6ebc1 inline continue...
kono
parents: 508
diff changeset
478 pdisp = pvartable-ldisp;
e58848f6ebc1 inline continue...
kono
parents: 508
diff changeset
479 for(i=ldisp;i<0;i++) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
480 heap[pdisp+i] = 0;
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
481 }
505
5d4112735c5c *** empty log message ***
kono
parents: 504
diff changeset
482 return pvartable;
462
kono
parents:
diff changeset
483 }
kono
parents:
diff changeset
484
795
a4fd2ab28e24 i64 va_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
485 extern int
462
kono
parents:
diff changeset
486 p_lvar(int e1)
kono
parents:
diff changeset
487 {
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
488 int sz = is_memory(e1);
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
489 int d = cadr(e1);
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
490 int d1,e;
502
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
491 if ((d1=(heap[pdisp+d]))) return d1;
574
aad312f61654 remove too much inmode.
kono
parents: 569
diff changeset
492 fprintf(stderr,"## undeclared ivar %d\n",d);
795
a4fd2ab28e24 i64 va_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
493 error(-1);
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
494 e = heap[pdisp+d]=list3(LVAR,new_lvar(sz),0);
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
495 inline_lvars = glist2(e,inline_lvars);
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
496 return e;
462
kono
parents:
diff changeset
497 }
kono
parents:
diff changeset
498
kono
parents:
diff changeset
499 static int
kono
parents:
diff changeset
500 pfunction(int e)
kono
parents:
diff changeset
501 {
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
502 // list4(INLINE,e1,arglist,ftype);
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
503 // include code segement case
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
504 int e1 = pexpr(cadr(e));
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
505 int arglist = caddr(e);
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
506 int newargs = 0;
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
507 int ftype = cadddr(e);
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
508 int e3;
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
509 for (e3 = arglist; e3; e3 = cadr(e3)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
510 newargs = list3( pexpr(car(e3)), newargs, caddr(e3));
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
511 }
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
512 newargs = reverse0(newargs);
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
513 return list4(car(e),e1,newargs,ftype);
462
kono
parents:
diff changeset
514 }
kono
parents:
diff changeset
515
kono
parents:
diff changeset
516 static int
kono
parents:
diff changeset
517 prindirect(int e)
kono
parents:
diff changeset
518 {
818
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
519 #if 0
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
520 int offset = caddr(e);
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
521 int e1 = pexpr(cadr(e));
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
522 e1 = binop(ADD,e1,list2(CONST,offset),list2(POINTER,type),INT);
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
523 type = cadddr(e);
819
dc8df3977c17 lvar offset in prindirect
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 818
diff changeset
524 if (car(e1)==LVAR) return rvalue(e1);
dc8df3977c17 lvar offset in prindirect
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 818
diff changeset
525 if (OP(car(e1))==REGISTER && car(cadr(e))==IVAR) return rvalue(e1);
dc8df3977c17 lvar offset in prindirect
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 818
diff changeset
526 return list3(car(e),e1,0);
818
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
527 #else
525
d84cea14dbdc *** empty log message ***
kono
parents: 524
diff changeset
528 int lvar;
533
80b5058f0535 inline code-gen test passed.
kono
parents: 532
diff changeset
529 int offset = caddr(e);
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
530 int type0;
819
dc8df3977c17 lvar offset in prindirect
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 818
diff changeset
531 if (offset!=0) error(-1);
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
532 type = cadddr(e);
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
533 type0 = type_value(type);
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
534 if (type0>0 && car(type0)==POINTER)
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
535 type=set_type_with_attr(cadr(type),type);
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
536 if (car(lvar=cadr(e))==IVAR) {
830
ff5dfee80829 INDIRECT handling in pexpr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 828
diff changeset
537 lvar=p_lvar(cadr(e)); // can be anything....
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
538 switch(car(lvar)) {
830
ff5dfee80829 INDIRECT handling in pexpr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 828
diff changeset
539 case LVAR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
540 type = cadddr(e);
828
d0f48d1ea798 rvalue_t separation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 822
diff changeset
541 return rvalue(lvar);
818
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
542 case REGISTER: case DREGISTER:
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
543 case FREGISTER: case LREGISTER:
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
544 case CONST: case FCONST: case DCONST: case LCONST:
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
545 // should do type check
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
546 if (offset) error(-1);
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
547 return lvar;
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
548 default:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
549 error(-1);
818
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
550 }
819
dc8df3977c17 lvar offset in prindirect
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 818
diff changeset
551 }
830
ff5dfee80829 INDIRECT handling in pexpr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 828
diff changeset
552 int e2 = pexpr(cadr(e));
835
59ebc5cb2a99 array offset peep hole
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 834
diff changeset
553 if (car(e2)==INDIRECT) e2 = cadr(e2);
834
51b230253f27 rindirect offset peep hole
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
554 if (OP(car(e2))==ADD) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
555 int c = caddr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
556 if (car(c)==CONST) { e2 = cadr(e2); offset = cadr(c); }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
557 else if (car(c)==LCONST) { e2 = cadr(e2); offset = lcadr(c); }
834
51b230253f27 rindirect offset peep hole
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 832
diff changeset
558 }
830
ff5dfee80829 INDIRECT handling in pexpr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 828
diff changeset
559 return list3(car(e),e2,offset);
818
c59753132812 remove rvalue_t from CONV
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 801
diff changeset
560 #endif
462
kono
parents:
diff changeset
561 }
kono
parents:
diff changeset
562
kono
parents:
diff changeset
563 static int
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
564 pindirect(int e)
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
565 {
553
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
566 //int lvar;
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
567 //if (car(lvar=cadr(e))==IVAR)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
568 // lvar=p_lvar(cadr(e)); // can be anything....
831
a22aabb27786 pdecl_data type
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 830
diff changeset
569 #if 1
830
ff5dfee80829 INDIRECT handling in pexpr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 828
diff changeset
570 return pexpr(cadr(e));
ff5dfee80829 INDIRECT handling in pexpr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 828
diff changeset
571 #else
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
572 return list3(car(e),pexpr(cadr(e)),caddr(e));
830
ff5dfee80829 INDIRECT handling in pexpr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 828
diff changeset
573 #endif
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
574 }
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
575
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
576 static int
462
kono
parents:
diff changeset
577 paddress(int e)
kono
parents:
diff changeset
578 {
601
6b808480f08b strcut, array parse tree in inmode.
kono
parents: 599
diff changeset
579 // if (car(cadr(e))==INDIRECT) return pexpr(cadr(cadr(e)));
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
580 return list2(car(e),pexpr(cadr(e)));
462
kono
parents:
diff changeset
581 }
kono
parents:
diff changeset
582
kono
parents:
diff changeset
583 static int
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
584 p_conv(int e1,int e2)
462
kono
parents:
diff changeset
585 {
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
586 int t,stype = type;
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
587 if (is_const(e2) && (t=type_of_conv(e1))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
588 type = INT;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
589 e1 = correct_type(e2,t);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
590 type = stype;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
591 return e1;
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
592 }
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
593 return list3(CONV,pexpr(e2),e1);
462
kono
parents:
diff changeset
594 }
kono
parents:
diff changeset
595
kono
parents:
diff changeset
596 static int
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
597 pbinop(int op,int e1,int e2)
462
kono
parents:
diff changeset
598 {
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
599 e1 = pexpr(e1);
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
600 e2 = pexpr(e2);
819
dc8df3977c17 lvar offset in prindirect
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 818
diff changeset
601 if (is_const(e1)||is_const(e2)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
602 int t;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
603 if((t= type_of_bop(op)))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
604 return binop(OP(op),e1,e2,t,t);
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
605 }
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
606 return list3(op,e1,e2);
502
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
607 }
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
608
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
609 static int
526
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
610 plor(int op,int e1,int e2)
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
611 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
612 int e = pexpr(e1);
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
613 return list3(op,e,pexpr(e2));
526
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
614 }
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
615
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
616 static int
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
617 pland(int op,int e1,int e2)
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
618 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
619 int e = pexpr(e1);
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
620 return list3(op,e,pexpr(e2));
526
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
621 }
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
622
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
623 static int
462
kono
parents:
diff changeset
624 psassign(int e)
kono
parents:
diff changeset
625 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
626 int e1 = pexpr(cadr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
627 int e2 = pexpr(caddr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
628 return list4(car(e),e1,e2,cadddr(e));
462
kono
parents:
diff changeset
629 }
kono
parents:
diff changeset
630
kono
parents:
diff changeset
631 static int
kono
parents:
diff changeset
632 passign(int e)
kono
parents:
diff changeset
633 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
634 int e1 = pexpr(cadr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
635 int e2 = pexpr(caddr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
636 return list3(car(e),e1,e2);
462
kono
parents:
diff changeset
637 }
kono
parents:
diff changeset
638
kono
parents:
diff changeset
639 static int
kono
parents:
diff changeset
640 passop(int e)
kono
parents:
diff changeset
641 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
642 int e1 = pexpr(cadr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
643 int e2 = pexpr(caddr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
644 return list4(car(e),e1,e2,cadddr(e));
462
kono
parents:
diff changeset
645 }
kono
parents:
diff changeset
646
kono
parents:
diff changeset
647 static int
kono
parents:
diff changeset
648 pdassign(int e)
kono
parents:
diff changeset
649 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
650 int e1 = pexpr(cadr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
651 int e2 = pexpr(caddr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
652 return list3(car(e),e1,e2);
462
kono
parents:
diff changeset
653 }
kono
parents:
diff changeset
654
kono
parents:
diff changeset
655 static int
kono
parents:
diff changeset
656 pdassop(int e)
kono
parents:
diff changeset
657 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
658 int e1 = pexpr(cadr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
659 int e2 = pexpr(caddr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
660 return list4(car(e),e1,e2,cadddr(e));
462
kono
parents:
diff changeset
661 }
kono
parents:
diff changeset
662
kono
parents:
diff changeset
663 static int
kono
parents:
diff changeset
664 plassign(int e)
kono
parents:
diff changeset
665 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
666 int e1 = pexpr(cadr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
667 int e2 = pexpr(caddr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
668 return list3(car(e),e1,e2);
462
kono
parents:
diff changeset
669 }
kono
parents:
diff changeset
670
kono
parents:
diff changeset
671 static int
kono
parents:
diff changeset
672 plassop(int e)
kono
parents:
diff changeset
673 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
674 int e1 = pexpr(cadr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
675 int e2 = pexpr(caddr(e));
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
676 return list4(car(e),e1,e2,cadddr(e));
462
kono
parents:
diff changeset
677 }
kono
parents:
diff changeset
678
kono
parents:
diff changeset
679 static int
kono
parents:
diff changeset
680 palloc(int e)
kono
parents:
diff changeset
681 {
695
3e69986a7b82 *** empty log message ***
kono
parents: 692
diff changeset
682 int e1 = pexpr(e);
3e69986a7b82 *** empty log message ***
kono
parents: 692
diff changeset
683 if (car(e1)==CONST)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
684 return list2(ADDRESS,list3(LVAR,new_lvar_align(cadr(e1),16),0));
695
3e69986a7b82 *** empty log message ***
kono
parents: 692
diff changeset
685 return list2(ALLOCA,e1);
462
kono
parents:
diff changeset
686 }
kono
parents:
diff changeset
687
kono
parents:
diff changeset
688 static int
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
689 pcomma(int e1,int e2)
462
kono
parents:
diff changeset
690 {
556
ef225b589888 s-dandy fix
kono
parents: 555
diff changeset
691 int e = pexpr(e1);
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
692 return list3(COMMA,e,pexpr(e2));
462
kono
parents:
diff changeset
693 }
kono
parents:
diff changeset
694
kono
parents:
diff changeset
695 static int
kono
parents:
diff changeset
696 prbit_field(int e)
kono
parents:
diff changeset
697 {
822
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
698 int e1 = list3(car(e),pexpr(cadr(e)),caddr(e));
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
699 type = cadr(caddr(e)); // value type
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
700 return e1;
462
kono
parents:
diff changeset
701 }
kono
parents:
diff changeset
702
kono
parents:
diff changeset
703 static int
kono
parents:
diff changeset
704 pbassign(int e)
kono
parents:
diff changeset
705 {
553
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
706 // list4(BASS,e1,e2,list2(BASS,t)));
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
707 int e1=pexpr(caddr(e));
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
708 return list4(car(e),pexpr(cadr(e)),e1,cadddr(e));
462
kono
parents:
diff changeset
709 }
kono
parents:
diff changeset
710
kono
parents:
diff changeset
711 static int
kono
parents:
diff changeset
712 pbassop(int e)
kono
parents:
diff changeset
713 {
695
3e69986a7b82 *** empty log message ***
kono
parents: 692
diff changeset
714 int e1 = caddr(e);
3e69986a7b82 *** empty log message ***
kono
parents: 692
diff changeset
715 if (car(e)==BASSOP) e1=pexpr(e1);
553
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
716 return list4(car(e),pexpr(cadr(e)),e1,cadddr(e));
462
kono
parents:
diff changeset
717 }
kono
parents:
diff changeset
718
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
719 /*
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
720 variable initialization with offset
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
721 */
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
722
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
723 static int
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
724 passign_data(int var,int target_type, int e,int t,int offset)
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
725 {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
726 int ass,sz,bfd;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
727
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
728 #if STRUCT_ALIGN
786
3ebbec5a72dc i64 strinit inlined struct init does not zero fill
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 785
diff changeset
729 if (t!=EMPTY) {
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
730 int strtype=0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
731 if (t>0 && (car(t)==STRUCT||car(t)==UNION))
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
732 strtype=1;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
733 sz = size(t);
794
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 788
diff changeset
734 if (lp64 && (sz%size_of_longlong==0||strtype)) {
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 788
diff changeset
735 offset = align(offset,size_of_longlong);
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 788
diff changeset
736 } else if (sz%size_of_int==0||strtype) {
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 788
diff changeset
737 offset = align(offset,size_of_int);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
738 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
739 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
740 #endif
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
741 if (car(e)==ADDRESS||car(e)==GVAR) {
702
8eadf0db2970 *** empty log message ***
kono
parents: 701
diff changeset
742 if (scalar(t)) {
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
743 t = list2(POINTER,VOID); // fake
702
8eadf0db2970 *** empty log message ***
kono
parents: 701
diff changeset
744 } else if (t>0 && car(t)==ARRAY) {
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
745 } else {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
746 error(TYERR);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
747 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
748 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
749 if (t==EMPTY) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
750 /* empty space in partial initialization */
886
9a4b92984cf1 inline struct initialization in an expression
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 881
diff changeset
751 zfill(var,offset,cadr(e));
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
752 return offset+cadr(e);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
753 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
754 type = t;
702
8eadf0db2970 *** empty log message ***
kono
parents: 701
diff changeset
755 // e = rvalue_t(e,t);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
756 if (!scalar(type) && (type>0 && (car(type)!=ADDRESS && car(type)!=ARRAY)))
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
757 e = correct_type(e,target_type);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
758 /* If this is a local declared constant, we don't have to assign.
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
759 But some one may take it's address. We have to generate assign.
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
760 */
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
761 ass = assign_expr0(
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
762 offset?
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
763 lp64?list3(LADD,var,llist2(LCONST,offset)): // binop?
770
b674d8421430 i64 inline ( indirect call )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 767
diff changeset
764 list3(ADD,var,list2(CONST,offset)):
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
765 var,
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
766 e,target_type,t); // already correct_typed
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
767 init_vars = list2(ass,init_vars);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
768 if (t>0&&car(t)==BIT_FIELD) {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
769 sz = 0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
770 bfd = cadr(caddr(t)); /* bit_field_disp */
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
771 #if BIT_FIELD_CODE
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
772 code_bit_field_disp(t,&offset,&bfd,&sz);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
773 #endif
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
774 return offset+sz;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
775 }
785
33d9a4b05bc8 i64 decl_data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
776 return offset+size(target_type);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
777 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
778
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
779 static int pdecl_data(int var, int target_type, int init,int offset);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
780
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
781 static void
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
782 pflush_decl_data(int var,int sz)
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
783 {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
784 int offset;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
785 int offset0=0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
786 int e;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
787 int t,offset1=0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
788 int smode=mode;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
789 int init = decl_str_init;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
790
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
791 decl_str_init = 0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
792 mode = STADECL;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
793 /*
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
794 decl_str_init
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
795 output delayed decl data
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
796 list4(offset,next,expression,list2(type0,type1));
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
797 */
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
798 while (init) {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
799 offset= car(init);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
800 e=caddr(init);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
801 t=car(cadddr(init)); // type of source
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
802 type=cadr(cadddr(init)); // destination type
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
803 if (offset!=offset0) {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
804 // make space
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
805 passign_data(var,EMPTY,list2(CONST,offset-offset0),EMPTY,offset0);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
806 }
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
807 e = pexpr(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
808 // offset0 = passign_data(var,type,e,t,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
809 offset0 = pdecl_data(var,type,e,offset);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
810 init = cadr(init);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
811 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
812 offset = offset0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
813 if ((sz=(offset1+sz-offset))>0)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
814 passign_data(var,EMPTY,list2(CONST,sz),EMPTY,offset0);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
815 local_nptr = 0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
816 mode=smode;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
817 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
818
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
819 static int
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
820 str_init_eq()
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
821 {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
822 // error(-1); // duplicate struct field value
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
823 return 2; // allow override keep unique
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
824 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
825
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
826
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
827 static int
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
828 pdecl_data_array(int var,int init,int target_type,int offset)
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
829 {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
830 int type0 = cadr(target_type); /* array item type */
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
831 int e;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
832
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
833 for(; init; init = cadr(init)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
834 // unordered data with tag or array offset
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
835 if (car(init)!=DECL_DATA_ARRAY) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
836 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
837 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
838 e = pexpr(caddr(init));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
839 offset = pdecl_data(var,type0,e,offset);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
840 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
841 return offset;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
842 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
843
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
844 static int
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
845 pdecl_data_field(int var,int init,int target_type,int offset)
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
846 {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
847 int type0 = target_type; /* list of fields */
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
848 int e,t,type1,foffset;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
849 NMTBL *n;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
850
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
851 for(; init; init = cadr(init)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
852 // unordered data with tag or array offset
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
853 if (car(init)!=DECL_DATA_FIELD) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
854 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
855 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
856 n = ncadddr(init);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
857 type1 = search_struct_type(type0,n->nm,&foffset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
858 e = caddr(init);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
859 if (car(e)!=DECL_DATA) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
860 t = caddr(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
861 decl_str_init=insert_ascend(decl_str_init,
881
ab501cdbbefd fix wrong src/dst type in pdecl_data_field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 880
diff changeset
862 glist4(offset+foffset,0,e,glist2(t,type1)),str_init_eq);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
863 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
864 return offset;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
865 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
866
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
867 static int
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
868 pdecl_data_list(int var,int init,int target_type,int offset)
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
869 {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
870 int type0 = caddr(target_type); /* list of fields */
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
871 int e;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
872
703
874adc2528f9 strinit fix on parse mode (half done)
kono
parents: 702
diff changeset
873 for(; init; init = cadr(init),type0 = cadr(type0)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
874 if (car(init)==DECL_DATA) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
875 // casted initilizer ?
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
876 //error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
877 e = cadr(init); // value
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
878 if (!e) continue; // {...,} case
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
879 e = pexpr(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
880 offset = pdecl_data(var,caddr(init),e,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
881 continue;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
882 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
883 // ordered data
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
884 if (car(init)!=DECL_DATA_LIST) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
885 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
886 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
887 e = caddr(init);
889
6a92d3e8a4b5 expr14 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 888
diff changeset
888 if (!e) { // {...,} case, zerofill
6a92d3e8a4b5 expr14 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 888
diff changeset
889 offset = passign_data(var,EMPTY,list2(CONST,size(target_type)),EMPTY,offset);
6a92d3e8a4b5 expr14 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 888
diff changeset
890 continue;
6a92d3e8a4b5 expr14 reorganization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 888
diff changeset
891 }
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
892 e = pexpr(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
893 offset = pdecl_data(var,car(type0),e,offset);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
894 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
895 return offset;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
896 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
897
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
898 static int
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
899 pdecl_data(int var, int target_type, int init,int offset)
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
900 {
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
901 int t,e;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
902 int save_decl_str_init = decl_str_init;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
903 decl_str_init = 0;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
904 target_type = type_value(target_type);
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
905
692
6785c63f0558 decl_data static incomplete
kono
parents: 691
diff changeset
906 if (init==0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
907 return offset;
692
6785c63f0558 decl_data static incomplete
kono
parents: 691
diff changeset
908 }
682
639db8597a58 decl_data optimization
kono
parents: 681
diff changeset
909 e = cadr(init);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
910 if (car(init)==DECL_DATA) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
911 switch(car(e)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
912 case DECL_DATA_LIST:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
913 offset = pdecl_data_list(var,e,target_type,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
914 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
915 case DECL_DATA_FIELD:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
916 offset = pdecl_data_field(var,e,target_type,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
917 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
918 case DECL_DATA_ARRAY:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
919 offset = pdecl_data_array(var,e,target_type,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
920 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
921 default:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
922 type = caddr(init);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
923 e = rvalue(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
924 e = pexpr(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
925 t = caddr(init); // type of source
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
926 offset = passign_data(var,target_type,e,t,offset);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
927 }
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
928 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
929 error(-1);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
930 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
931 if (decl_str_init) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
932 int sz = size(target_type);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
933 pflush_decl_data(var,sz);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
934 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
935 decl_str_init = save_decl_str_init;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
936 return offset;
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
937 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
938
561
de0b0380c461 comments
kono
parents: 558
diff changeset
939 // handle local variable declaration
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
940 // initialization is accumrated in init argument
561
de0b0380c461 comments
kono
parents: 558
diff changeset
941 // should consider int k=some_compile_time_constant;
462
kono
parents:
diff changeset
942 static int
kono
parents:
diff changeset
943 p_decl(int e)
kono
parents:
diff changeset
944 {
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
945 // list4(ST_DECL,parse,(int)n,list3(mode,stmode,ctmode),init);
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
946 int ctmode=caddr(e);
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
947 NMTBL *n=ncaddddr(e);
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
948 int dsp = n->dsp;
569
1fcad06b264a gcc4 (ia32)
kono
parents: 566
diff changeset
949 int v=0;
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
950 int sstmode = stmode;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
951 int smode = mode;
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
952 int save_init_vars = init_vars;
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
953 int init = cadddr(e); // variable initialization
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
954
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
955 init_vars = 0;
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
956 // in real partial evaluation, we have to check whether this variable
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
957 // is used or not.
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
958 if (ctmode) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
959 mode = car(ctmode); stmode = cadr(ctmode); ctmode = caddr(ctmode);
574
aad312f61654 remove too much inmode.
kono
parents: 569
diff changeset
960 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
961 mode = LDECL; stmode = 0; ctmode = 0;
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
962 }
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
963 switch(stmode) {
528
d6fff671793a minor fix inline
kono
parents: 527
diff changeset
964 case EXTRN: case EXTRN1: case STATIC:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
965 // def(n,ctmode); we don't need this. already done.
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
966 // stmode = sstmode;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
967 if (init) error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
968 stmode = sstmode;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
969 mode = smode;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
970 init_vars = save_init_vars;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
971 return pexpr(cadr(e));
529
ad874ef77dde use_input_reg...
kono
parents: 528
diff changeset
972 #if 1
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
973 case REGISTER:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
974 switch(n->ty) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
975 case ULONGLONG: case LONGLONG:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
976 v = get_lregister_var(n); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
977 case FLOAT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
978 v = get_dregister_var(n,0); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
979 case DOUBLE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
980 v = get_dregister_var(n,1); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
981 default:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
982 if (scalar(n->ty))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
983 v = get_register_var(n);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
984 else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
985 error(TYERR);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
986 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
987 break;
528
d6fff671793a minor fix inline
kono
parents: 527
diff changeset
988 #endif
701
bf4fd39737e9 fix static in parse mode
kono
parents: 699
diff changeset
989 // case LLDECL: LLDECL is mode, not stmode (bad design)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
990 // v = list2(FLABEL,fwdlabel()); break;
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
991 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
992 if (mode==STADECL) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
993 if (init) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
994 v = list3n(GVAR,0,n);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
995 gen_decl_data(init,v);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
996 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
997 stmode = sstmode;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
998 mode = smode;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
999 init_vars = save_init_vars;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1000 return pexpr(cadr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1001 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1002 if (n->sc==FLABEL)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1003 v = list3n(LVAR,fwdlabel(),n);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1004 else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1005 NMTBL tn;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1006 tn = *n;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1007 code_lvar_alignment(disp,&tn,n->ty,size(n->ty));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1008 v = list3n(LVAR,tn.dsp,n);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1009 }
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1010 }
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1011 if (n->sc!=FLABEL)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1012 inline_lvars = glist2(v,inline_lvars);
574
aad312f61654 remove too much inmode.
kono
parents: 569
diff changeset
1013 if (heap[pdisp+dsp]) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1014 fprintf(stderr,"## double p_decl %s %s\n",(ncaddr(heap[pdisp+dsp]))->nm,n->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1015 error(-1);
574
aad312f61654 remove too much inmode.
kono
parents: 569
diff changeset
1016 }
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1017 heap[pdisp+dsp]=v;
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1018 stmode = sstmode;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1019 mode = smode;
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
1020 if (init) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1021 pdecl_data(v,n->ty,init,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1022 if (init_vars) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1023 int e1 = pexpr(cadr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1024 init_vars = reverse0(init_vars);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1025 while (init_vars) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1026 e1 = list3(ST_COMP,e1,car(init_vars));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1027 init_vars = cadr(init_vars);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1028 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1029 init_vars = save_init_vars;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1030 return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1031 }
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
1032 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
1033 init_vars = save_init_vars;
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1034 return pexpr(cadr(e));
462
kono
parents:
diff changeset
1035 }
kono
parents:
diff changeset
1036
kono
parents:
diff changeset
1037 static int
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1038 p_if(int e1)
462
kono
parents:
diff changeset
1039 {
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1040 int cond,l1,l2;
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1041 int e2=caddr(e1),e3;
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1042 cond = pexpr(car(e2));
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1043 // conv->if_then_();
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1044 l1 = pexpr(cadr(e2));
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1045 if ((e3=caddr(e2))) { // else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1046 l2 = pexpr(e3);
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1047 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1048 l2 = 0;
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1049 }
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1050 return list3(ST_IF,pexpr(cadr(e1)),list3(cond,l1,l2));
462
kono
parents:
diff changeset
1051 }
kono
parents:
diff changeset
1052
kono
parents:
diff changeset
1053 static int
kono
parents:
diff changeset
1054 p_do(int e)
kono
parents:
diff changeset
1055 {
524
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1056 int e2 = pexpr(caddr(e));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1057 int e3 = pexpr(cadddr(e));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1058 return list4(ST_DO,pexpr(cadr(e)),e2,e3);
462
kono
parents:
diff changeset
1059 }
kono
parents:
diff changeset
1060
kono
parents:
diff changeset
1061 static int
kono
parents:
diff changeset
1062 p_while(int e)
kono
parents:
diff changeset
1063 {
524
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1064 int e2 = pexpr(caddr(e));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1065 int e3 = pexpr(cadddr(e));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1066 return list4(ST_WHILE,pexpr(cadr(e)),e2,e3);
462
kono
parents:
diff changeset
1067 }
kono
parents:
diff changeset
1068
kono
parents:
diff changeset
1069 static int
kono
parents:
diff changeset
1070 p_for(int e)
kono
parents:
diff changeset
1071 {
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1072 int e1=caddr(e);
524
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1073 int p0=pexpr(car(e1));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1074 int p1=pexpr(cadr(e1));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1075 int p2=pexpr(caddr(e1));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1076 int p3=pexpr(cadddr(e1));
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1077 // unfolding for constant case?
524
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1078 return list3(ST_FOR,pexpr(cadr(e)), list4(p0,p1,p2,p3));
462
kono
parents:
diff changeset
1079 }
kono
parents:
diff changeset
1080
kono
parents:
diff changeset
1081 static int
kono
parents:
diff changeset
1082 p_switch(int e)
kono
parents:
diff changeset
1083 {
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1084 int e2 = pexpr(caddr(e)); // switch variable
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1085 int e3 = pexpr(cadddr(e)); // a statement in switch
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1086 // if cadr(e) is a constant, we have to prune case statement.
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1087 // No we cannot. A statement in case may contain labels or
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1088 // falling down entry.
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1089 // case constants are need to be pexpred in p_case.
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1090
524
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1091 return list4(ST_SWITCH,pexpr(cadr(e)),e2,e3);
462
kono
parents:
diff changeset
1092 }
kono
parents:
diff changeset
1093
kono
parents:
diff changeset
1094 static int
kono
parents:
diff changeset
1095 p_comp(int e)
kono
parents:
diff changeset
1096 {
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1097 int e1;
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1098 e1=pexpr(caddr(e));
524
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1099 return list3(ST_COMP,pexpr(cadr(e)),e1);
462
kono
parents:
diff changeset
1100 }
kono
parents:
diff changeset
1101
kono
parents:
diff changeset
1102 static int
kono
parents:
diff changeset
1103 p_break(int e)
kono
parents:
diff changeset
1104 {
502
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
1105 return list2(ST_BREAK,pexpr(cadr(e)));
462
kono
parents:
diff changeset
1106 }
kono
parents:
diff changeset
1107
kono
parents:
diff changeset
1108 static int
kono
parents:
diff changeset
1109 p_continue(int e)
kono
parents:
diff changeset
1110 {
502
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
1111 return list2(ST_CONTINUE,pexpr(cadr(e)));
462
kono
parents:
diff changeset
1112 }
kono
parents:
diff changeset
1113
kono
parents:
diff changeset
1114 static int
kono
parents:
diff changeset
1115 p_case(int e)
kono
parents:
diff changeset
1116 {
506
96af6754acd3 *** empty log message ***
kono
parents: 505
diff changeset
1117 int new=0,clist = caddr(e);
96af6754acd3 *** empty log message ***
kono
parents: 505
diff changeset
1118 // insert destory clist, we have to copy it now
690
5d3b4669854c fix prindirect
kono
parents: 687
diff changeset
1119 // car(clist) have to be expred, it may contain operators.
506
96af6754acd3 *** empty log message ***
kono
parents: 505
diff changeset
1120 for(;clist;clist=cadr(clist))
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1121 // new=glist3(cexpr(pexpr(car(clist))),new,0);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1122 new=glist3(car(clist),new,0);
506
96af6754acd3 *** empty log message ***
kono
parents: 505
diff changeset
1123 return list3(ST_CASE,pexpr(cadr(e)),reverse0(new));
462
kono
parents:
diff changeset
1124 }
kono
parents:
diff changeset
1125
kono
parents:
diff changeset
1126 static int
kono
parents:
diff changeset
1127 p_default(int e)
kono
parents:
diff changeset
1128 {
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1129 // should be removed if case value is a constant
502
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
1130 return list2(ST_DEFAULT,pexpr(cadr(e)));
462
kono
parents:
diff changeset
1131 }
kono
parents:
diff changeset
1132
kono
parents:
diff changeset
1133 static int
kono
parents:
diff changeset
1134 p_return(int e)
kono
parents:
diff changeset
1135 {
524
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1136 int e1=pexpr(caddr(e));
135afeb2e134 inline first work. no constant propagation.
kono
parents: 519
diff changeset
1137 return list3(ST_RETURN,pexpr(cadr(e)),e1);
462
kono
parents:
diff changeset
1138 }
kono
parents:
diff changeset
1139
kono
parents:
diff changeset
1140 static int
kono
parents:
diff changeset
1141 p_goto(int e)
kono
parents:
diff changeset
1142 {
555
ac181d7f9c82 IA32 eval order
kono
parents: 554
diff changeset
1143 int e1,lb,e2;
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1144 if ((e1=caddr(e))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1145 switch(car(e1)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1146 case RINDIRECT: e1=pexpr(e1); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1147 case CODE: e2=pexpr(cadr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1148 e1=list3(JUMP,e2,pexpr(caddr(e1))); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1149 case FLABEL: /* error(-1); */ break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1150 case IVAR:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1151 lb = cadr(e1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1152 if (!(e1=heap[pdisp+lb])) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1153 e1 = heap[pdisp+lb]=list2(FLABEL,fwdlabel());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1154 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1155 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1156 case JUMP:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1157 e1 = list3(JUMP,pexpr(cadr(e1)),pexpr(caddr(e1)));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1158 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1159 default:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1160 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1161 }
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1162 }
502
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
1163 return list3(ST_GOTO,pexpr(cadr(e)),e1);
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1164 }
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1165
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1166 static int
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1167 p_list_expr(int e)
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1168 {
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1169 int e3,new = 0;
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1170 for (e3 = e; e3; e3 = cadr(e3)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1171 new= list2( pexpr(car(e3)), new);
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1172 }
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1173 return reverse0(new);
462
kono
parents:
diff changeset
1174 }
kono
parents:
diff changeset
1175
kono
parents:
diff changeset
1176 static int
kono
parents:
diff changeset
1177 p_asm(int e)
kono
parents:
diff changeset
1178 {
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1179 int param=caddr(e);
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1180 int e1 = p_list_expr(cadddr(e));
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1181 return list4(ST_ASM,pexpr(cadr(e)),param,e1);
462
kono
parents:
diff changeset
1182 }
kono
parents:
diff changeset
1183
kono
parents:
diff changeset
1184 static int
kono
parents:
diff changeset
1185 p_label(int e)
kono
parents:
diff changeset
1186 {
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1187 int e1,lb;
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1188 if ((e1=caddr(e))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1189 switch(car(e1)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1190 case FLABEL: /* error(-1); */ break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1191 case IVAR:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1192 lb = cadr(e1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1193 if (!(e1=heap[pdisp+lb])) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1194 e1 = heap[pdisp+lb]=list2(FLABEL,fwdlabel());
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1195 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1196 }
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1197 }
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1198 return list3(ST_LABEL,pexpr(cadr(e)),e1);
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1199 }
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1200
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1201 static int
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1202 p_label_var(int e)
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1203 {
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1204 int d,e1;
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1205 switch(car(e1=e)) {
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1206 case LVAR: /* error(-1) */ break;
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1207 case IVAR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1208 // should this done in p_decl? (in __label__?)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1209 d = cadr(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1210 if (!(e1=(heap[pdisp+d]))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1211 // error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1212 e1 = heap[pdisp+d]=list3(LVAR,fwdlabel(),caddr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1213 }
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1214 }
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1215 return list2(LABEL,e1);
462
kono
parents:
diff changeset
1216 }
kono
parents:
diff changeset
1217
kono
parents:
diff changeset
1218 static int
kono
parents:
diff changeset
1219 p_bool(int e)
kono
parents:
diff changeset
1220 {
501
a63eb2319d11 inline continue...
kono
parents: 500
diff changeset
1221 error(-1);
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
1222 return e;
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
1223 }
462
kono
parents:
diff changeset
1224
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
1225 static int
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
1226 p_comment(int e)
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
1227 {
574
aad312f61654 remove too much inmode.
kono
parents: 569
diff changeset
1228 glineno++;
713
88e364604533 *** empty log message ***
kono
parents: 712
diff changeset
1229 plineno = caddr(e);
88e364604533 *** empty log message ***
kono
parents: 712
diff changeset
1230 return list4n(ST_COMMENT,pexpr(cadr(e)),caddr(e),ncadddr(e));
462
kono
parents:
diff changeset
1231 }
kono
parents:
diff changeset
1232
508
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1233 static int
512
53ec17a8af7d inline continue....
kono
parents: 511
diff changeset
1234 p_inline(int e)
508
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1235 {
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1236 int e3;
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1237 int narg;
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1238
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1239 /* inline function arguments */
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1240 narg = 0;
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1241 for (e3 = caddr(e); e3; e3 = cadr(e3)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1242 narg=list3(pexpr(car(e3)),narg,caddr(e3));
508
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1243 }
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1244 return list4(INLINE,cadr(e),reverse0(narg),cadddr(e));
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1245 }
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1246
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1247 extern int
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1248 pexpr(int e1)
462
kono
parents:
diff changeset
1249 {
kono
parents:
diff changeset
1250 int e2,e3;
kono
parents:
diff changeset
1251
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1252 // if (inmode) error(-1);
502
bc66e49e25a2 inline continue...
kono
parents: 501
diff changeset
1253 if (e1==0) return 0;
462
kono
parents:
diff changeset
1254 e2 = cadr(e1);
kono
parents:
diff changeset
1255 switch (car(e1)){
kono
parents:
diff changeset
1256 case GVAR: case RGVAR: case CRGVAR: case CURGVAR: case SRGVAR:
788
fcb642ef08c9 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 786
diff changeset
1257 case URGVAR:
462
kono
parents:
diff changeset
1258 case SURGVAR: case REGISTER:
kono
parents:
diff changeset
1259 case DREGISTER: case FREGISTER:
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1260 case FRGVAR: case DRGVAR:
462
kono
parents:
diff changeset
1261 case LREGISTER:
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1262 case LRGVAR: case LURGVAR:
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1263 case CONST:
462
kono
parents:
diff changeset
1264 case DCONST: case FCONST:
kono
parents:
diff changeset
1265 case LCONST:
kono
parents:
diff changeset
1266 case STRING:
778
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 770
diff changeset
1267 case STRINGS:
462
kono
parents:
diff changeset
1268 case FNAME:
503
3c95c69aa80e *** empty log message ***
kono
parents: 502
diff changeset
1269 case FLABEL:
616
2ba903c8e749 builtin_fabs
kono
parents: 609
diff changeset
1270 case BUILTIN_INF:
2ba903c8e749 builtin_fabs
kono
parents: 609
diff changeset
1271 case BUILTIN_INFF:
2ba903c8e749 builtin_fabs
kono
parents: 609
diff changeset
1272 case BUILTIN_INFL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1273 return e1;
551
73ebe9d82a9c inline (scope.c/GNU extension) continue...
kono
parents: 549
diff changeset
1274 case LABEL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1275 return p_label_var(e2);
831
a22aabb27786 pdecl_data type
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 830
diff changeset
1276 case LVAR: case URLVAR:
462
kono
parents:
diff changeset
1277 case RLVAR: case CRLVAR: case CURLVAR: case SRLVAR: case SURLVAR:
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1278 case FRLVAR: case DRLVAR:
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1279 case LRLVAR: case LURLVAR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1280 return e1;
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1281 case IVAR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1282 return p_lvar(e1);
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1283 case CODE:
462
kono
parents:
diff changeset
1284 case FUNCTION:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1285 return pfunction(e1);
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
1286 case JUMP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1287 e2 = pexpr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1288 return list3(car(e1),e2,pexpr(cadddr(e1)));
601
6b808480f08b strcut, array parse tree in inmode.
kono
parents: 599
diff changeset
1289 case ARRAY:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1290 e2 = pexpr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1291 e1 = binop(ADD,e2,pexpr(caddr(e1)),cadddr(e1),caddddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1292 return indop(e1);
601
6b808480f08b strcut, array parse tree in inmode.
kono
parents: 599
diff changeset
1293 case PERIOD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1294 e2 = pexpr(e2);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1295 nptr = ncadddr(e1);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1296 type = caddr(e1);
601
6b808480f08b strcut, array parse tree in inmode.
kono
parents: 599
diff changeset
1297 return strop(e2,0);
6b808480f08b strcut, array parse tree in inmode.
kono
parents: 599
diff changeset
1298 case ARROW:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1299 type = caddr(e1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1300 e2 = rvalue(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1301 e2 = pexpr(e2);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1302 nptr = ncadddr(e1);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1303 type = caddr(e1);
601
6b808480f08b strcut, array parse tree in inmode.
kono
parents: 599
diff changeset
1304 return strop(e2,1);
462
kono
parents:
diff changeset
1305 case INLINE:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1306 return p_inline(e1);
462
kono
parents:
diff changeset
1307 case INDIRECT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1308 return pindirect(e1);
462
kono
parents:
diff changeset
1309 case RINDIRECT: case URINDIRECT:
kono
parents:
diff changeset
1310 case CRINDIRECT: case CURINDIRECT:
kono
parents:
diff changeset
1311 case SRINDIRECT: case SURINDIRECT:
kono
parents:
diff changeset
1312 case FRINDIRECT: case DRINDIRECT:
kono
parents:
diff changeset
1313 case LRINDIRECT: case LURINDIRECT:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1314 return prindirect(e1);
462
kono
parents:
diff changeset
1315 case ADDRESS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1316 return paddress(e1);
566
ddc435b64fc8 binop/inline interaction
kono
parents: 561
diff changeset
1317 case ST_OP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1318 e3=caddr(e1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1319 e1=pexpr(car(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1320 return binop0(e2,e1,pexpr(cadr(e3)),caddr(e3),cadddr(e3));
462
kono
parents:
diff changeset
1321 case MINUS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1322 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1323 if (car(e3)==CONST) return list2(CONST,-cadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1324 return list2(car(e1),e3);
462
kono
parents:
diff changeset
1325 #if LONGLONG_CODE
kono
parents:
diff changeset
1326 case LMINUS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1327 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1328 if (car(e3)==LCONST) return llist2(LCONST,-lcadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1329 return list2(car(e1),e3);
462
kono
parents:
diff changeset
1330 #endif
kono
parents:
diff changeset
1331 #if FLOAT_CODE
kono
parents:
diff changeset
1332 case DMINUS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1333 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1334 if (car(e3)==DCONST) return dlist2(DCONST,-dcadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1335 if (car(e3)==FCONST) return dlist2(FCONST,-dcadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1336 return list2(car(e1),e3);
462
kono
parents:
diff changeset
1337 case FMINUS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1338 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1339 if (car(e3)==DCONST) return dlist2(DCONST,-dcadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1340 if (car(e3)==FCONST) return dlist2(FCONST,-dcadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1341 return list2(car(e1),e3);
462
kono
parents:
diff changeset
1342 #endif
kono
parents:
diff changeset
1343 case CONV:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1344 return p_conv(caddr(e1),e2);
462
kono
parents:
diff changeset
1345 case BNOT: /* ~ */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1346 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1347 if (car(e3)==CONST) return list2(CONST,~cadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1348 return list2(BNOT,e3);
462
kono
parents:
diff changeset
1349 case LNOT: /* ! */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1350 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1351 if (car(e3)==CONST) return list2(CONST,!cadr(e3));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1352 return list2(LNOT,e3);
462
kono
parents:
diff changeset
1353 case PREINC:
kono
parents:
diff changeset
1354 case UPREINC:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1355 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1356 if (car(e3)==CONST) return list2(CONST,cadr(e3)+caddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1357 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1358 case POSTINC:
kono
parents:
diff changeset
1359 case UPOSTINC:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1360 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1361 if (car(e3)==CONST) return e3;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1362 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1363 #if FLOAT_CODE
kono
parents:
diff changeset
1364 case DPREINC: /* ++d */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1365 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1366 if (car(e3)==FCONST) return dlist2(FCONST,dcadr(e3)+cadr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1367 if (car(e3)==DCONST) return dlist2(DCONST,dcadr(e3)+cadr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1368 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1369 case DPOSTINC: /* d++ */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1370 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1371 if (car(e3)==FCONST||car(e3)==DCONST) return e3;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1372 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1373 case FPREINC: /* ++f */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1374 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1375 if (car(e3)==FCONST) return dlist2(FCONST,dcadr(e3)+cadr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1376 if (car(e3)==DCONST) return dlist2(DCONST,dcadr(e3)+cadr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1377 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1378 case FPOSTINC: /* f++ */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1379 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1380 if (car(e3)==FCONST||car(e3)==DCONST) return e3;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1381 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1382 #endif
kono
parents:
diff changeset
1383 #if LONGLONG_CODE
kono
parents:
diff changeset
1384 case LPREINC: /* ++d */
kono
parents:
diff changeset
1385 case LUPREINC: /* ++d */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1386 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1387 if (car(e3)==LCONST) return llist2(LCONST,lcadr(e3)+cadr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1388 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1389 case LPOSTINC: /* d++ */
kono
parents:
diff changeset
1390 case LUPOSTINC: /* d++ */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1391 if ((e3 = pexpr(e2))==e2) return e1;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1392 if (car(e3)==LCONST) return e3;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1393 return list4(car(e1),e3,caddr(e1),cadddr(e1));
462
kono
parents:
diff changeset
1394 #endif
kono
parents:
diff changeset
1395 case MUL: case UMUL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1396 case DIV: case UDIV:
462
kono
parents:
diff changeset
1397 case MOD: case UMOD:
kono
parents:
diff changeset
1398 case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT:
kono
parents:
diff changeset
1399 case ADD: case SUB: case BAND: case EOR: case BOR: case CMP: case CMPGE:
kono
parents:
diff changeset
1400 case UCMP: case CMPEQ: case CMPNEQ: case UCMPGE:
kono
parents:
diff changeset
1401 #if FLOAT_CODE
kono
parents:
diff changeset
1402 case DMUL: case DDIV:
kono
parents:
diff changeset
1403 case DADD: case DSUB:
kono
parents:
diff changeset
1404 case DCMP: case DCMPGE: case DCMPEQ: case DCMPNEQ:
kono
parents:
diff changeset
1405 case FMUL: case FDIV:
kono
parents:
diff changeset
1406 case FADD: case FSUB:
kono
parents:
diff changeset
1407 case FCMP: case FCMPGE: case FCMPEQ: case FCMPNEQ:
kono
parents:
diff changeset
1408 #endif
kono
parents:
diff changeset
1409 #if LONGLONG_CODE
kono
parents:
diff changeset
1410 case LMUL: case LUMUL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1411 case LDIV: case LUDIV:
462
kono
parents:
diff changeset
1412 case LMOD: case LUMOD:
kono
parents:
diff changeset
1413 case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT:
kono
parents:
diff changeset
1414 case LADD: case LSUB: case LBAND: case LEOR: case LBOR: case LCMP:
kono
parents:
diff changeset
1415 #endif
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1416 return pbinop(car(e1),e2,caddr(e1));
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1417 // relational operator
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1418 case GT: case UGT: case GE: case UGE: case LT:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1419 case ULT: case LE: case ULE:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1420 case LOP+GT: case LOP+UGT: case LOP+GE: case LOP+UGE: case LOP+LT:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1421 case LOP+ULT: case LOP+LE: case LOP+ULE:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1422 case DOP+GT: case DOP+GE: case DOP+LT: case DOP+LE:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1423 case FOP+GT: case FOP+GE: case FOP+LT: case FOP+LE:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1424 case FOP+EQ: case FOP+NEQ:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1425 case EQ: case NEQ: case DOP+EQ: case DOP+NEQ:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1426 case LOP+EQ: case LOP+NEQ:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1427 return pbinop(car(e1),e2,caddr(e1));
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1428 case LAND:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1429 return pland(car(e1),cadr(e1),caddr(e1));
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1430 case LOR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1431 return plor(car(e1),cadr(e1),caddr(e1));
528
d6fff671793a minor fix inline
kono
parents: 527
diff changeset
1432 case LCOND: case DCOND: case FCOND: case COND: case UCOND: case LUCOND:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1433 e2 = pexpr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1434 if (car(e2)==CONST) return
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1435 caddr(e1)? pexpr(cadr(e2)?caddr(e1):cadddr(e1)) :
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1436 pexpr(cadr(e2)?e2:cadddr(e1)); // GNU extension h?:g
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1437 e3=pexpr(caddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1438 return list4(car(e1),e2,e3,pexpr(cadddr(e1)));
462
kono
parents:
diff changeset
1439 case STASS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1440 return psassign(e1);
462
kono
parents:
diff changeset
1441 case ASS: case CASS: case SASS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1442 return passign(e1);
462
kono
parents:
diff changeset
1443 case SASSOP: case SUASSOP:
kono
parents:
diff changeset
1444 case ASSOP: case CASSOP: case CUASSOP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1445 return passop(e1);
462
kono
parents:
diff changeset
1446 #if FLOAT_CODE
kono
parents:
diff changeset
1447 case FASS: case DASS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1448 return pdassign(e1);
462
kono
parents:
diff changeset
1449 case DASSOP: case FASSOP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1450 return pdassop(e1);
616
2ba903c8e749 builtin_fabs
kono
parents: 609
diff changeset
1451
2ba903c8e749 builtin_fabs
kono
parents: 609
diff changeset
1452 case BUILTIN_FABS:
2ba903c8e749 builtin_fabs
kono
parents: 609
diff changeset
1453 case BUILTIN_FABSF:
2ba903c8e749 builtin_fabs
kono
parents: 609
diff changeset
1454 case BUILTIN_FABSL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1455 e2 = pexpr(e2);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1456 if (is_const(e2)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1457 if (dcadr(e2) >= 0.0 ) return e2;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1458 return pexpr(list2(car(e1)==BUILTIN_FABSF?
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1459 FMINUS:DMINUS,e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1460 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1461 return list2(car(e1),e2);
462
kono
parents:
diff changeset
1462 #endif
kono
parents:
diff changeset
1463 #if LONGLONG_CODE
kono
parents:
diff changeset
1464 case LASS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1465 return plassign(e1);
462
kono
parents:
diff changeset
1466 case LASSOP: case LUASSOP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1467 return plassop(e1);
462
kono
parents:
diff changeset
1468 #endif
kono
parents:
diff changeset
1469 case ALLOCA:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1470 return palloc(e2);
462
kono
parents:
diff changeset
1471 case BUILTINP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1472 return list2(CONST,is_const(pexpr(e2)));
462
kono
parents:
diff changeset
1473 case COMMA:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1474 return pcomma(e2,caddr(e1));
462
kono
parents:
diff changeset
1475 case RETURN:
kono
parents:
diff changeset
1476 case ENVIRONMENT:
kono
parents:
diff changeset
1477 case LCALL:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1478 return e1;
462
kono
parents:
diff changeset
1479 #if BIT_FIELD_CODE
kono
parents:
diff changeset
1480 case RBIT_FIELD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1481 return prbit_field(e1);
553
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
1482 case BIT_FIELD:
293f827ccfb2 Linux kernel source compiled.
kono
parents: 552
diff changeset
1483 return list3(BIT_FIELD,pexpr(e2),caddr(e1));
462
kono
parents:
diff changeset
1484 case BASS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1485 return pbassign(e1);
462
kono
parents:
diff changeset
1486 case BPREINC:
kono
parents:
diff changeset
1487 case BPOSTINC:
kono
parents:
diff changeset
1488 case BASSOP:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1489 return pbassop(e1);
462
kono
parents:
diff changeset
1490 #endif
kono
parents:
diff changeset
1491 #if ASM_CODE
kono
parents:
diff changeset
1492 case ASM:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1493 return list3(ASM,list4(
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1494 car(e2),cadr(e2),caddr(e2),cadddr(e2)),
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1495 caddr(e1));
462
kono
parents:
diff changeset
1496 #endif
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
1497 case CAST:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1498 if (e2==0) {
890
9d5da127f462 inline partial struct init in declaration.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 889
diff changeset
1499 error(-1);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1500 return 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1501 } else if (car(e2)==DECL_DATA) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1502 // casted initialized structure (struct hoge){...}
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1503 return list3(DECL_DATA,pexpr(cadr(e2)),caddr(e2));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1504 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1505 if (type_compatible(caddr(e1),cadddr(e1))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1506 return pexpr(e2); // rvalue ?
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1507 } else {
822
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
1508 #if 1
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1509 e2 = pexpr(e2); // will override type
822
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
1510 type = cadddr(e1);
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
1511 return correct_type(e2,caddr(e1));
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
1512 #else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1513 e2 = pexpr(e2); // will override type
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1514 e2 = correct_type(e2,caddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1515 type = caddr(e1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1516 return e2;
822
8e7241d81f66 parse mode/non parse mode on ppc, ia32, i64
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 819
diff changeset
1517 #endif
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1518 // return list4(CAST,pexpr(e2),caddr(e1),cadddr(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1519 }
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
1520 case DECL_DATA:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1521 return list3(DECL_DATA,pexpr(e2),caddr(e1));
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
1522 case DECL_DATA_LIST:
697
e31cba38f7fc *** empty log message ***
kono
parents: 696
diff changeset
1523 case DECL_DATA_ARRAY:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1524 return list4(car(e1),pexpr(e2),pexpr(caddr(e1)),cadddr(e1));
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 648
diff changeset
1525 case DECL_DATA_FIELD:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1526 return list4n(car(e1),pexpr(e2),pexpr(caddr(e1)),ncadddr(e1));
462
kono
parents:
diff changeset
1527 case ST_DECL: return p_decl(e1);
kono
parents:
diff changeset
1528 case ST_IF: return p_if(e1);
kono
parents:
diff changeset
1529 case ST_DO: return p_do(e1);
kono
parents:
diff changeset
1530 case ST_WHILE: return p_while(e1);
kono
parents:
diff changeset
1531 case ST_FOR: return p_for(e1);
kono
parents:
diff changeset
1532 case ST_SWITCH: return p_switch(e1);
kono
parents:
diff changeset
1533 case ST_COMP: return p_comp(e1);
kono
parents:
diff changeset
1534 case ST_BREAK: return p_break(e1);
kono
parents:
diff changeset
1535 case ST_CONTINUE: return p_continue(e1);
kono
parents:
diff changeset
1536 case ST_CASE: return p_case(e1);
kono
parents:
diff changeset
1537 case ST_DEFAULT: return p_default(e1);
kono
parents:
diff changeset
1538 case ST_RETURN: return p_return(e1);
kono
parents:
diff changeset
1539 case ST_GOTO: return p_goto(e1);
kono
parents:
diff changeset
1540 case ST_ASM: return p_asm(e1);
kono
parents:
diff changeset
1541 case ST_LABEL: return p_label(e1);
kono
parents:
diff changeset
1542 case ST_COMMENT: return p_comment(e1);
kono
parents:
diff changeset
1543 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1544 error(-1);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1545 return p_bool(e1);
462
kono
parents:
diff changeset
1546 }
kono
parents:
diff changeset
1547 return VOID;
kono
parents:
diff changeset
1548 }
kono
parents:
diff changeset
1549
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1550 /*
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1551 Prepare pvariable table
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1552 */
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1553
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1554 static int
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1555 replace_inline_parameter(NMTBL *anptr,int t,int e4,int narg,int evals)
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1556 {
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1557 int arg;
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1558 if (has_attr(anptr,KONST) && !has_attr(anptr,HAS_ADDRESS)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1559 // replacable const variable
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1560 if (is_memory(e4)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1561 heap[pdisp+narg]=reference(e4);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1562 return evals;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1563 } else if (is_const(e4)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1564 heap[pdisp+narg]=e4;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1565 return evals;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1566 }
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1567 }
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1568 // we need real local variable for this inline
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1569 arg = heap[pdisp+narg]=list3n(LVAR,new_lvar(size(t)),anptr);
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1570 inline_lvars = glist2(arg,inline_lvars);
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1571 evals=list2(assign_expr0(arg,e4,anptr->ty,t),evals);
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1572 return evals;
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1573 }
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1574
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1575 /*
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1576 setup parameter replacement of inline call
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1577 */
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1578
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1579 static void
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1580 enter_inline(NMTBL *n, int e,int toplevel)
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1581 {
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1582 int e1 = attr_value(n,INLINE);
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1583 int arg_disp = cadr(e1); // number of arguments
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1584 int narg,e3,e4, e5, fargtype;
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1585 int evals = 0;
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1586 int t, replace;
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1587 NMTBL *anptr;
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1588
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1589 fnptr = n; // st_return see this
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1590 pvartable = p_vartable(arg_disp, /* number of arg */
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1591 caddr(e1) /* number of local parameter */);
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1592
704
6e6dc2d644ed *** empty log message ***
kono
parents: 703
diff changeset
1593 replace = (is_code(fnptr)||toplevel);
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1594
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1595 /* function arguments type */
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1596 fargtype = n->dsp; // we cannot do destruct reverse here
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1597
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1598 /* inline function arguments */
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1599 narg = 0;
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1600 if (!fargtype) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1601 goto no_args; // wrong number of arguments
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1602 }
699
0bc5f2ff86cc code segement argument offset in parse mode.
kono
parents: 697
diff changeset
1603
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1604 for (e3 = e5 = reverse0(caddr(e)); e3; e3 = cadr(e3)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1605 anptr = ncadddr(fargtype);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1606 if (!anptr) break; // should not happen?
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1607 t=caddr(e3); // type
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1608 e4 = car(e3);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1609 if (replace) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1610 heap[pdisp+narg]=reference(e4);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1611 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1612 evals = replace_inline_parameter(anptr,t,e4,narg,evals);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1613 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1614 narg ++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1615 fargtype = cadr(fargtype);
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1616 }
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1617 caddr(e) = reverse0(e5); // make it normal
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1618 if (eval_order==NORMAL) evals = reverse0(evals);
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1619 for(;evals;evals=cadr(evals)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1620 g_expr_u(car(evals));
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1621 }
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1622 no_args:
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1623 return;
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1624 }
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1625
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1626 /*
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1627 pass local static variable list to our parents
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1628 clean up and free used inline parameters
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1629 */
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1630
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1631 static void
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1632 leave_inline(int e1,int toplevel)
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1633 {
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1634 NMTBL *n;
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
1635 NMTBL *local_statics = ncadddr(e1); // local static list
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1636
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1637 if (retcont && !toplevel) error(STERR);
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1638 // inline can't handle return/environment except top level
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1639
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1640 if (local_statics && local_statics != &null_nptr) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1641 // append our local static variables to the parent list
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1642 n = local_statics;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1643 while(n->next != &null_nptr) n=n->next;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1644 n->next = local_static_list; local_static_list = local_statics;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1645 ncadddr(e1) = 0; // prevent duplicate initialize
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1646 }
625
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1647
4b4c6b1ea69a *** empty log message ***
kono
parents: 616
diff changeset
1648 // free used local variables or registers
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1649 while(inline_lvars) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1650 int e;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1651 int l = car(inline_lvars);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1652 switch(car(l)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1653 case LVAR: free_lvar(cadr(l)); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1654 case REGISTER: case DREGISTER:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1655 case FREGISTER: case LREGISTER:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1656 free_register(cadr(l));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1657 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1658 e = cadr(inline_lvars);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1659 free_glist2(inline_lvars);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1660 inline_lvars = e;
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1661 }
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1662 }
530
58aceee8e4b4 get_lregister messed up
kono
parents: 529
diff changeset
1663
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1664 extern int
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1665 gen_inline(int e, int toplevel)
462
kono
parents:
diff changeset
1666 {
514
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1667 // these saved value should be some struct
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1668 int sretlabel;
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1669 NMTBL *sfnptr;
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1670 int svartable;
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1671
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1672 int scslabel = cslabel;
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1673 int sdisp = pdisp;
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1674 int sret_register;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1675 int sret_reg_mode;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1676 int sinline_lvars;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1677 int slfree;
531
19f5882997f5 *** empty log message ***
kono
parents: 530
diff changeset
1678 // int slreg_count=lreg_count;
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1679
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1680 NMTBL *n = (NMTBL*)ncaddr(cadr(e));
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1681 int e1 = attr_value(n,INLINE);
500
0a4ca939f403 inline continue...
kono
parents: 464
diff changeset
1682 int parse = car(e1); // inline parse tree
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1683 int dots;
508
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1684 int ret_type = function_type(cadddr(e),&dots);
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1685
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1686 checkret();
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1687 checkjmp(-1);
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1688
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1689 svartable = pvartable;
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1690
552
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1691 scslabel = cslabel;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1692 sdisp = pdisp;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1693 sret_register = ret_register;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1694 sret_reg_mode = ret_reg_mode;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1695 sinline_lvars = inline_lvars;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1696 slfree=lfree;
74bbea56b8e5 inline scope with gcc extension passed.
kono
parents: 551
diff changeset
1697 // int slreg_count=lreg_count;
514
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1698
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1699 sretlabel = retlabel;
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1700 sfnptr = fnptr;
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1701
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1702 cslabel = -1;
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1703 retpending = 0;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
1704 inline_lvars = 0;
705
0554b7f985ee parse mode done.
kono
parents: 704
diff changeset
1705 if (!toplevel) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1706 retlabel = fwdlabel();
705
0554b7f985ee parse mode done.
kono
parents: 704
diff changeset
1707 }
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1708
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1709 enter_inline(n,e,toplevel);
526
9ff5cd7afe2f *** empty log message ***
kono
parents: 525
diff changeset
1710
704
6e6dc2d644ed *** empty log message ***
kono
parents: 703
diff changeset
1711 if (toplevel) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1712 ret_register = code_set_return_register(0); // fnptr required
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1713 ret_reg_mode = 1;
704
6e6dc2d644ed *** empty log message ***
kono
parents: 703
diff changeset
1714 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1715 ret_register = 555;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1716 ret_reg_mode = 0;
704
6e6dc2d644ed *** empty log message ***
kono
parents: 703
diff changeset
1717 }
6e6dc2d644ed *** empty log message ***
kono
parents: 703
diff changeset
1718
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1719 // partial evaluation of parse tree
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1720 // constant propergation, etc.
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1721 parse = pexpr(parse);
463
50a59dfb4606 inline continue...
kono
parents: 462
diff changeset
1722 pdisp = sdisp;
464
d88f08d81bba inline continue....
kono
parents: 463
diff changeset
1723 pvartable = svartable;
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1724
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1725 // generate code if necessary
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1726 if (ret_type!=VOID)
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1727 g_expr0(parse);
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1728 else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1729 g_expr_u(parse);
557
c3053086f790 a little partial evaluation.
kono
parents: 556
diff changeset
1730
705
0554b7f985ee parse mode done.
kono
parents: 704
diff changeset
1731 if (!toplevel) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1732 checkret();
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1733 fwddef(retlabel);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 835
diff changeset
1734 control=1;
705
0554b7f985ee parse mode done.
kono
parents: 704
diff changeset
1735 }
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1736
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1737 leave_inline(e1,toplevel);
510
2bd6ff6ee9a8 inline continue...
kono
parents: 509
diff changeset
1738
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1739 fnptr = sfnptr;
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1740 retlabel = sretlabel;
696
7f0f92380714 code segment parse tree fix (incomplete)
kono
parents: 695
diff changeset
1741
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1742 cslabel = scslabel;
514
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1743 ret_register = sret_register;
a2047e4555be inline continue....
kono
parents: 513
diff changeset
1744 ret_reg_mode = sret_reg_mode;
527
6b0fd56848e6 inline continue....
kono
parents: 526
diff changeset
1745 inline_lvars = sinline_lvars;
528
d6fff671793a minor fix inline
kono
parents: 527
diff changeset
1746 lfree=slfree;
513
4c2607e72ab5 inline continue... fix function call
kono
parents: 512
diff changeset
1747
508
d8102a46b78d inline test routine first compile passed.
kono
parents: 506
diff changeset
1748 return ret_type;
462
kono
parents:
diff changeset
1749 }
kono
parents:
diff changeset
1750
kono
parents:
diff changeset
1751 /* end */