annotate mc-codegen.c @ 89:917947ffeb7c

power pc version
author kono
date Thu, 06 Mar 2003 23:47:42 +0900
parents 5c8553d7f984
children 9b1aeb62e0b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1 /* Micro-C Generic Code Generatation Part */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2 /* $Id$ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
4 #define EXTERN extern
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
5 #include "mc.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
6 #include "mc-codegen.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
7 #include "mc-code.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
8
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
9 int creg; /* current register */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
10 int dreg; /* temporary register */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
11 int reg_sp; /* REGister Stack-Pointer */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
12
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
13 int rname[MAX_MAX];
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
14 int regs[MAX_MAX]; /* 使われているレジスタを示すフラグ */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
15 int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
16 int regv[MAX_MAX]; /* 値が入っているかどうか */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
17
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
18 /* floating point registers */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
19
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
20 int freg; /* current floating point register */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
21 int greg; /* current floating point register */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
22 int freg_sp; /* floating point REGister Stack-Pointer */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
23
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
24 int frname[MAX_MAX];
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
25 int fregs[MAX_MAX]; /* 使われているレジスタを示すフラグ */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
26 int freg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
27 int fregv[MAX_MAX]; /* 値が入っているかどうか */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
28
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
29 int use; /* generated value will be used */
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
30
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
31 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
32 creg currrent virtual register
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
33 dreg spare virtual register
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
34
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
35 rname[creg] currrent real register
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
36 rname[dreg] spare real register
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
37
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
38 regs[] virtual register usage
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
39 regv[] value in virtual register flag
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
40
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
41 reg_name[rname[creg]]
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
42
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
43 freg current floating point register
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
44 fregv calue in floating point register
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
45 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
46
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
47 void remove0(int *parent,int e) ;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
48 void remove0_all(int *parent,int e) ;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
49 int is_same_type(int e1,int e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
50 void jump(int e1, int env);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
51 void machinop(int e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
52 void sassign(int e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
53 void assign(int e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
54 void assop(int e1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
55 void g_expr0(int e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
56
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
57 void
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
58 gexpr(int e1,int use0)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
59 {
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
60 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
61 gexpr_init();
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
62 use = use0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
63 #if 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
64 if(lineno==2862) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
65 g_expr0(e1); /*break here*/
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
66 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
67 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
68 #endif
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
69 g_expr0(e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
70 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
71
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
72 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
73 csvalue()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
74 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
75 return rname[creg]; /* for switch value */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
76 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
77
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
78 void
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
79 g_expr_u(int e1)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
80 {
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
81 int suse = use; use=0;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
82 g_expr0(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
83 use=suse;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
84 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
85
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
86 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
87 g_expr(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
88 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
89 int suse = use; use=1;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
90 g_expr0(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
91 use=suse;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
92 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
93
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
94 void
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
95 g_expr0(int e1)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
96 {
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
97 int e2,e3;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
98 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
99
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
100 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
101 switch (car(e1)){
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
102 case GVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
103 code_gvar(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
104 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
105 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
106 case RGVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
107 code_rgvar(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
108 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
109 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
110 case CRGVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
111 code_crgvar(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
112 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
113 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
114 case LVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
115 code_lvar(lvar(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
116 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
117 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
118 case REGISTER:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
119 /* this is of course redundant... */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
120 /* we can use rname for this? */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
121 /* or why not creg=e2? */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
122 code_register(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
123 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
124 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
125 case RLVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
126 code_rlvar(lvar(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
127 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
128 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
129 case CRLVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
130 code_crlvar(lvar(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
131 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
132 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
133 case FRLVAR:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
134 code_drlvar(lvar(e2),0);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
135 fregv[freg]=1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
136 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
137 case FRGVAR:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
138 code_drgvar(e1,0);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
139 fregv[freg]=1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
140 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
141 case DRLVAR:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
142 code_drlvar(lvar(e2),1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
143 fregv[freg]=1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
144 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
145 case DRGVAR:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
146 code_drgvar(e1,1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
147 fregv[freg]=1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
148 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
149 case FNAME:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
150 code_fname(((NMTBL *)(e2))->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
151 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
152 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
153 case CONST: /* 代入する値が0でも特別な処理はしない */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
154 code_const(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
155 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
156 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
157 case DCONST:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
158 code_dconst(e1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
159 fregv[freg]=1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
160 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
161 case STRING:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
162 string(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
163 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
164 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
165 case FUNCTION:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
166 function(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
167 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
168 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
169 case CODE:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
170 jump(e2,caddr(e1));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
171 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
172 case INDIRECT:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
173 g_expr0(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
174 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
175 case RINDIRECT: case CRINDIRECT:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
176 case DRINDIRECT: case FRINDIRECT:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
177 rindirect(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
178 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
179 case ADDRESS:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
180 g_expr0(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
181 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
182 case MINUS: /* レジスタに対し、neglを実行すれば実現可能 */
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
183 g_expr0(e2); code_neg();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
184 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
185 case DMINUS:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
186 g_expr0(e2); code_dneg();
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
187 return;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
188 case I2D:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
189 g_expr0(e2); code_i2d();
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
190 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
191 case D2I:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
192 g_expr0(e2); code_d2i();
3789aef7331d minor fix
kono
parents: 84
diff changeset
193 return;
3789aef7331d minor fix
kono
parents: 84
diff changeset
194 case U2D:
3789aef7331d minor fix
kono
parents: 84
diff changeset
195 g_expr0(e2); code_u2d();
3789aef7331d minor fix
kono
parents: 84
diff changeset
196 return;
3789aef7331d minor fix
kono
parents: 84
diff changeset
197 case D2U:
3789aef7331d minor fix
kono
parents: 84
diff changeset
198 g_expr0(e2); code_d2u();
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
199 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
200 case BNOT: /* ~ */
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
201 g_expr0(e2); code_not();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
202 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
203 case LNOT: /* ! */
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
204 g_expr0(e2); code_lnot();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
205 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
206 case PREINC:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
207 code_preinc(e1,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
208 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
209 case POSTINC:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
210 code_postinc(e1,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
211 return;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
212 case DPREINC:
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
213 code_dpreinc(e1,e2,1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
214 return;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
215 case DPOSTINC:
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
216 code_dpostinc(e1,e2,1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
217 return;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
218 case FPREINC:
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
219 code_dpreinc(e1,e2,0);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
220 return;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
221 case FPOSTINC:
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
222 code_dpostinc(e1,e2,0);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
223 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
224 case CPOSTINC:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
225 /* char *p; *p++ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
226 code_cpostinc(e1,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
227 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
228 case CPREINC:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
229 code_cpreinc(e1,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
230 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
231 case CPOSTDEC:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
232 code_cpostdec(e1,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
233 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
234 case CPREDEC:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
235 code_cpredec(e1,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
236 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
237 case MUL: case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
238 case DIV: case UDIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
239 case MOD: case UMOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
240 case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
241 case ADD: case SUB: case BAND: case EOR: case BOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
242 machinop(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
243 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
244 case DMUL: case DDIV:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
245 case DADD: case DSUB:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
246 case DCMP:
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
247 dmachinop(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
248 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
249 case COND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
250 e2=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
251 b_expr(cadr(e1),0,e2,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
252 code_set_fixed_creg(0);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
253 g_expr0(caddr(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
254 /* e4 = rname[creg]; this is a bad idea */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
255 code_set_fixed_creg(1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
256 jmp(e3=fwdlabel());
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
257 fwddef(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
258 code_set_fixed_creg(0);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
259 g_expr0(cadddr(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
260 code_set_fixed_creg(1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
261 fwddef(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
262 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
263 case SASS:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
264 sassign(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
265 return;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
266 case ASS: case CASS:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
267 assign(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
268 return;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
269 case FASS: case DASS: case LASS:
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
270 dassign(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
271 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
272 case ASSOP: case CASSOP:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
273 assop(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
274 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
275 case DASSOP: case FASSOP:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
276 dassop(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
277 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
278 case RSTRUCT:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
279 g_expr0(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
280 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
281 case COMMA:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
282 g_expr_u(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
283 g_expr0(caddr(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
284 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
285 case RETURN:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
286 n = (NMTBL *)e2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
287 if (retcont==0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
288 retcont=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
289 code_return(creg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
290 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
291 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
292 case ENVIRONMENT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
293 code_environment(creg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
294 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
295 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
296 default:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
297 code_bool(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
298 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
299 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
300 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
301
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
302 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
303 bexpr(int e1, char cond, int l1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
304 {
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
305 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
306 gexpr_init();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
307 b_expr(e1,cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
308 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
309
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
310 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
311 b_expr(int e1, char cond, int l1,int err)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
312 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
313 int e2,l2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
314 e2=cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
315 switch(car(e1)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
316 case LNOT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
317 b_expr(e2,!cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
318 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
319 case GT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
320 rexpr(e1,l1,code_gt(cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
321 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
322 case UGT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
323 rexpr(e1,l1,code_ugt(cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
324 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
325 case GE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
326 rexpr(e1,l1,code_ge(cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
327 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
328 case UGE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
329 rexpr(e1,l1,code_uge(cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
330 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
331 case LT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
332 rexpr(e1,l1,code_ge(!cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
333 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
334 case ULT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
335 rexpr(e1,l1,code_uge(!cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
336 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
337 case LE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
338 rexpr(e1,l1,code_gt(!cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
339 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
340 case ULE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
341 rexpr(e1,l1,code_ugt(!cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
342 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
343 case EQ:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
344 rexpr(e1,l1,code_eq(cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
345 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
346 case NEQ:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
347 rexpr(e1,l1,code_eq(!cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
348 return;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
349
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
350 case DOP+GT:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
351 drexpr(cadr(e1),caddr(e1),l1,DOP+GT);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
352 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
353 case DOP+GE:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
354 drexpr(cadr(e1),caddr(e1),l1,DOP+GE);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
355 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
356 case DOP+LT:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
357 drexpr(caddr(e1),cadr(e1),l1,DOP+GT);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
358 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
359 case DOP+LE:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
360 drexpr(caddr(e1),cadr(e1),l1,DOP+GE);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
361 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
362 case DOP+EQ:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
363 drexpr(cadr(e1),caddr(e1),l1,DOP+EQ);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
364 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
365 case DOP+NEQ:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
366 drexpr(cadr(e1),caddr(e1),l1,DOP+NEQ);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
367 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
368
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
369 case LAND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
370 b_expr(e2,0,cond?(l2=fwdlabel()):l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
371 b_expr(caddr(e1),cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
372 if(cond) fwddef(l2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
373 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
374 case LOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
375 b_expr(e2,1,cond?l1:(l2=fwdlabel()),0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
376 b_expr(caddr(e1),cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
377 if(!cond) fwddef(l2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
378 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
379 case CRGVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
380 code_cmp_crgvar(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
381 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
382 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
383 case CRLVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
384 code_cmp_crlvar(lvar(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
385 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
386 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
387 case RGVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
388 code_cmp_rgvar(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
389 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
390 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
391 case RLVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
392 code_cmp_rlvar(lvar(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
393 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
394 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
395 case DRLVAR:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
396 code_cmp_drlvar(lvar(e2));
f94ca1168520 float first try...
kono
parents: 80
diff changeset
397 jcond(l1,cond);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
398 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
399 case DRGVAR:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
400 code_cmp_drgvar(lvar(e2));
f94ca1168520 float first try...
kono
parents: 80
diff changeset
401 jcond(l1,cond);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
402 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
403 case REGISTER:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
404 code_cmp_register(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
405 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
406 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
407 case CONST:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
408 if((cond&&e2)||(!cond&&!e2)) jmp(l1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
409 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
410 case DCONST:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
411 if((dcadr(e2)!=0.0)^cond) jmp(l1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
412 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
413 default:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
414 if(err) {
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
415 error(-1); return; /* recursive g_expr/b_expr */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
416 } /* type ? */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
417 g_expr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
418 code_cmp_register(creg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
419 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
420 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
421 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
422 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
423
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
424
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
425 void
917947ffeb7c power pc version
kono
parents: 88
diff changeset
426 arg_register(NMTBL *fnptr)
917947ffeb7c power pc version
kono
parents: 88
diff changeset
427 {
917947ffeb7c power pc version
kono
parents: 88
diff changeset
428 code_arg_register(fnptr->dsp);
917947ffeb7c power pc version
kono
parents: 88
diff changeset
429 }
917947ffeb7c power pc version
kono
parents: 88
diff changeset
430
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
431 /* goto arguments list */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
432 /* target list4(list2(tag,disp),cdr,ty,source_expr) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
433 /* source expr=listn(tag,...) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
434 /* source (after) list2(tag,disp) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
435 /* source list list3(e,cdr,sz) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
436
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
437 #define DEBUG_PARALLEL_ASSIGN 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
438
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
439 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
440 overrap(int t,int sz,int source)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
441 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
442 int s,s0,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
443 int t0=cadr(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
444 int t1=t0+sz;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
445 for(;source;source=cadr(source)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
446 s=car(source); s0=cadr(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
447 if(car(s)==REGISTER && car(t)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
448 if(s0==t0) return s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
449 } else if (is_same_type(s,t)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
450 s1=s0+caddr(source);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
451 #if DEBUG_PARALLEL_ASSIGN>1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
452 printf("# ovedrrap source %d t0 %d t1 %d\n",car(car(t)),t0,t1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
453 printf("# ovedrrap target %d s0 %d s1 %d\n",car(car(source)),s0,s1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
454 printf("# ovedrrap equal = %d\n",((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
455 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
456 if((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)) return s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
457 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
458 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
459 return 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
460 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
461
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
462 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
463 remove_target(int *target,int t,int *use)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
464 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
465 int use0=*use;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
466 while(use0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
467 if (car(use0)==t) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
468 free_register(caddr(use0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
469 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
470 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
471 use0 = cadr(use0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
472 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
473 remove0(target,t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
474 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
475
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
476 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
477 save_target(int t,int s,int *target,int *use,int sz,int ty)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
478 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
479 int e1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
480 /*新しいレジスタ(or スタック)を取得する*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
481 if (sz==size_of_int && (e1=get_register())!=-1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
482 *use=list3(t,*use,e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
483 e1=list2(REGISTER,e1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
484 g_expr_u(assign_expr0(e1,s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
485 *target = append4(*target,t,ty,e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
486 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
487 disp-=sz;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
488 g_expr_u(assign_expr0((e1=list2(LVAR,disp)),s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
489 *target = append4(*target,t,ty,e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
490 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
491 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
492
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
493 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
494 circular_dependency(int t,int s,int *target,int *source)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
495 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
496 int target0=*target;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
497 int t1,sz,ty,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
498 while(target0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
499 if (cadddr(target0)==s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
500 t1=car(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
501 s=cadddr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
502 sz=size(ty=caddr(target0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
503 if(t==t1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
504 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
505 printf("# circular dependency %d ty %d+%d sz %d\n",car(t1),ty,cadr(t1),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
506 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
507 return 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
508 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
509 if ((s1=overrap(t1,sz,*source))) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
510 /* another overrap start over */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
511 return circular_dependency(t,s1,target,source);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
512 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
513 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
514 target0=cadr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
515 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
516 return 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
517 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
518
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
519 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
520 parallel_assign(int *target,int *source,int *processing,int *use)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
521 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
522 int t,s,sz,ty,target0,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
523 while(*target) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
524 target0=*target;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
525 while(target0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
526 t=car(target0); s=cadddr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
527 sz=size(ty=caddr(target0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
528 if(car(t)==car(s) && cadr(t)==cadr(s)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
529 /*書き込み先が自分自身*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
530 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
531 printf("# remove same %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
532 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
533 remove_target(target,t,use);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
534 /* 破壊されては困るので、source listからは除かない */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
535 } else if (!(s1=overrap(t,sz,*source))) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
536 /* 重なってないので安心して書き込める */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
537 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
538 printf("# normal assign %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
539 #endif
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
540 g_expr_u(assign_expr0(t,s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
541 remove_target(target,t,use); remove0(source,s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
542 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
543 if(circular_dependency(t,s1,target,source)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
544 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
545 printf("# saving %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
546 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
547 remove_target(target,t,use); remove0(source,s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
548 save_target(t,s,target,use,sz,ty);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
549 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
550 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
551 target0=cadr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
552 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
553 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
554 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
555
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
556 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
557 remove0(int *parent,int e)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
558 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
559 int list;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
560 while ((list=*parent)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
561 if (car(list)==e) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
562 *parent= cadr(list); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
563 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
564 parent=&cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
565 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
566 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
567 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
568
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
569 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
570 remove0_all(int *parent,int e)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
571 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
572 int list;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
573 while ((list=*parent)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
574 if (car(list)==e) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
575 *parent= cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
576 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
577 parent=&cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
578 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
579 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
580 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
581
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
582 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
583 is_simple(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
584 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
585 return (
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
586 e1==CONST || e1==FNAME || e1==LVAR || e1==REGISTER ||
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
587 e1==GVAR || e1==RGVAR || e1==RLVAR || e1==CRLVAR || e1==CRGVAR ||
f94ca1168520 float first try...
kono
parents: 80
diff changeset
588 e1==DRLVAR || e1==FRLVAR
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
589 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
590 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
591
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
592 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
593 is_same_type(int e1,int e2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
594 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
595 int ce1=car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
596 int ce2=car(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
597 return (
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
598 (ce1==LVAR && (ce2==RLVAR||ce2==CRLVAR||ce2==FRLVAR||ce2==DRLVAR))
f94ca1168520 float first try...
kono
parents: 80
diff changeset
599 || (ce2==LVAR && (ce1==RLVAR||ce1==CRLVAR||ce1==FRLVAR||ce1==DRLVAR))
f94ca1168520 float first try...
kono
parents: 80
diff changeset
600 || (ce1==GVAR && (ce2==RGVAR||ce2==CRGVAR||ce2==FRGVAR||ce2==DRGVAR))
f94ca1168520 float first try...
kono
parents: 80
diff changeset
601 || (ce2==GVAR && (ce1==RGVAR||ce1==CRGVAR||ce1==FRGVAR||ce1==DRGVAR))
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
602 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
603 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
604
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
605 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
606 is_memory(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
607 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
608 int ce1=car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
609 return (
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
610 ce1==LVAR ||ce1==RLVAR||ce1==CRLVAR || ce1==DRLVAR ||
f94ca1168520 float first try...
kono
parents: 80
diff changeset
611 ce1==GVAR ||ce1==RGVAR||ce1==CRGVAR || ce1==DRGVAR ||
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
612 ce1==REGISTER
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
613 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
614 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
615
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
616 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
617 jump(int e1, int env)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
618 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
619 int e2,e3,e4,sz,arg_size,ty,max_regs,regs;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
620 int t0,s0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
621 NMTBL *code0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
622 int target = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
623 int source = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
624 int processing = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
625 int use = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
626
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
627 /* まず、サイズを計算しながら、決まった形に落す。 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
628
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
629 arg_size = 0; regs = 0; max_regs = MAX_REGISTER_VAR-1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
630 for (e3 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
631 e2 = car(e3); sz = size(ty=caddr(e3));
80
83d901658ce9 *** empty log message ***
kono
parents: 79
diff changeset
632 if (regs <= max_regs&&sz==size_of_int) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
633 target=list4(list2(REGISTER,register_var(regs++)), target,ty,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
634 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
635 target=list4(list2(LVAR,0), target,ty,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
636 arg_size += sz;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
637 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
638 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
639 printf("# target %d ty %d+%d sz %d\n",car(car(target)),ty,cadr(car(target)),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
640 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
641 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
642
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
643 /* disp を飛び先似合わせて修正 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
644 if (fnptr->sc==CODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
645 if (-arg_size<disp) disp = -arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
646 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
647 if (disp_offset-arg_size<disp) disp = disp_offset-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
648 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
649
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
650 /* 複雑な式を前もって計算しておく */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
651 /* 必要なら局所変数を用いる。 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
652 /* 局所変数へのオフセットを覚えておく */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
653
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
654 for (e2 = target; e2; e2 = cadr(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
655 t0=car(e2); s0=cadddr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
656 sz=size(ty=caddr(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
657 if(car(t0)==LVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
658 /* ここで、書込先アドレスを決める */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
659 cadr(t0)=-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
660 arg_size-=sz;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
661 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
662 if (!is_simple(car(s0))) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
663 disp-=sz;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
664 g_expr_u(assign_expr0((e4=list2(LVAR,disp)),s0,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
665 cadddr(e2)=e4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
666 s0=e4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
667 } else if (is_same_type(t0,s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
668 if(cadr(t0)==cadr(s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
669 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
670 printf("# remove same memory %d ty %d+%d sz %d\n",car(t0),ty,cadr(t0),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
671 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
672 /* we should check size also (but currently useless */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
673 remove0(&target,t0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
674 /* still we have source to avoid overwrite */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
675 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
676 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
677 if(is_memory(s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
678 source=list3(s0,source,sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
679 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
680 printf("# source %d ty %d+%d sz %d\n",car(car(source)),ty,cadr(car(source)),sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
681 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
682 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
683 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
684
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
685 /* compute jump address */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
686 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
687 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
688 code0=(NMTBL *)cadr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
689 if (code0->sc!=CODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
690 error(TYERR); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
691 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
692 } else { /* indirect */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
693 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
694 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
695 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
696 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
697 g_expr(env);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
698 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
699 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
700
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
701 /* 並列代入を実行 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
702
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
703 parallel_assign(&target,&source,&processing,&use);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
704 while (use) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
705 free_register(caddr(use)); use=cadr(use);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
706 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
707 if(target) error(-1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
708
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
709 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
710 /* change the frame pointer */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
711 e3 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
712 code_frame_pointer(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
713 emit_pop_free(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
714 } else if (fnptr->sc==FUNCTION) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
715 code_fix_frame_pointer(disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
716 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
717
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
718 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
719 code_jmp(code0->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
720 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
721 e2 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
722 code_indirect_jmp(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
723 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
724 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
725 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
726
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
727 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
728 machinop(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
729 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
730 int e2,e3,op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
731
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
732 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
733 op = car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
734 e3 = caddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
735 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
736 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
737 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
738 tosop(car(e1),(e2=pop_register()));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
739 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
740 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
741 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
742 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
743
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
744 void
f94ca1168520 float first try...
kono
parents: 80
diff changeset
745 dmachinop(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
746 {
f94ca1168520 float first try...
kono
parents: 80
diff changeset
747 int e2,e3,op;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
748
f94ca1168520 float first try...
kono
parents: 80
diff changeset
749 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
750 op = car(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
751 e3 = caddr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
752 g_expr(e3);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
753 emit_dpush();
f94ca1168520 float first try...
kono
parents: 80
diff changeset
754 g_expr(e2);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
755 dtosop(car(e1),(e2=dpop_register()));
f94ca1168520 float first try...
kono
parents: 80
diff changeset
756 emit_dpop_free(e2);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
757 fregv[freg]=1;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
758 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
759 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
760
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
761
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
762 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
763 sassign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
764 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
765 int e2,e3,e4,sz,xreg,det;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
766
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
767 /* structure assignment */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
768 e2 = cadr(e1); /* pointer variable to the struct */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
769 e3 = cadr(e2); /* offset of the variable (distination) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
770 e4 = caddr(e1); /* right value (source) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
771 sz = cadddr(e1); /* size of struct or union */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
772 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
773 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
774 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
775 xreg = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
776 /* 一般的にはコピーのオーバラップの状況は実行時にしかわからない */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
777 /* しかし、わかる場合もある */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
778 if (car(e4)==RSTRUCT) e4=cadr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
779 if (is_same_type(e2,e4)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
780 if(cadr(e2)<cadr(e4)) sz=-sz;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
781 det=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
782 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
783 det = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
784 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
785 emit_copy(xreg,creg,sz,0,1,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
786 emit_pop_free(xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
787 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
788 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
789
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
790 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
791 assign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
792 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
793 int e2,e3,e4,byte;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
794
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
795 byte=(car(e1) == CASS);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
796 /* e2=e4 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
797 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
798 e3 = cadr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
799 e4 = caddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
800 switch(car(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
801 case GVAR: /* i=3 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
802 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
803 code_assign_gvar(e2,byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
804 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
805 case LVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
806 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
807 code_assign_lvar(lvar(cadr(e2)),byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
808 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
809 case REGISTER:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
810 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
811 if (creg!=cadr(e2))
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
812 code_assign_register(cadr(e2),byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
813 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
814 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
815 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
816 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
817 use_data_reg(creg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
818 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
819 if (byte) use_data_reg(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
820 e2 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
821 code_assign(e2,byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
822 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
823 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
824 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
825 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
826
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
827 void
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
828 dassign(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
829 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
830 int e2,e3,e4,d;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
831
f94ca1168520 float first try...
kono
parents: 80
diff changeset
832 /* e2=e4 */
f94ca1168520 float first try...
kono
parents: 80
diff changeset
833 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
834 e3 = cadr(e2);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
835 e4 = caddr(e1);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
836 d = (car(e1)==LASS)?2:(car(e1)==DASS)?1:0;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
837 switch(car(e2)) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
838 case GVAR:
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
839 g_expr(e4);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
840 code_dassign_gvar(e2,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
841 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
842 case LVAR:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
843 g_expr(e4);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
844 code_dassign_lvar(lvar(cadr(e2)),d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
845 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
846 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
847 g_expr(e2);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
848 emit_push();
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
849 g_expr(e4);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
850 e2 = emit_pop(0);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
851 code_dassign(e2,d);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
852 emit_pop_free(e2);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
853 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
854 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
855
f94ca1168520 float first try...
kono
parents: 80
diff changeset
856 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
857 assop(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
858 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
859 int e2,e3,byte,op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
860
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
861 /* e2 op= e3 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
862 byte = (car(e1) == CASSOP);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
863 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
864 if (car(e2)==INDIRECT) e2=cadr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
865 e3 = caddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
866 op = cadddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
867
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
868 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
869 if (car(e2)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
870 code_register_assop(cadr(e2),op,byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
871 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
872 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
873 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
874 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
875 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
876 code_assop(op,byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
877 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
878 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
879 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
880
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
881 void
f94ca1168520 float first try...
kono
parents: 80
diff changeset
882 dassop(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
883 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
884 int e2,e3,op,d;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
885
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
886 /* e2 op= e3 */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
887 d = (car(e1) == DASSOP);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
888 e2 = cadr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
889 if (car(e2)==INDIRECT) e2=cadr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
890 e3 = caddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
891 op = cadddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
892
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
893 g_expr(e3);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
894 emit_dpush();
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
895 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
896 code_dassop(op,d);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
897 regv[creg]=1;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
898 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
899 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
900
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
901 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
902 fwdlabel(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
903 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
904 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
905 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
906
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
907 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
908 fwddef(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
909 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
910 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
911 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
912 printf("_%d:\n",l);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
913 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
914
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
915 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
916 backdef(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
917 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
918 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
919 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
920 printf("_%d:\n",labelno);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
921 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
922 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
923
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
924 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
925 def_label(int cslabel, int dlabel)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
926 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
927 int fl;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
928
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
929 fl = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
930 if (control) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
931 jmp(fl=fwdlabel());
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
932 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
933 fwddef(cslabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
934 if (dlabel)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
935 jmp(dlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
936 if (fl) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
937 fwddef(fl);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
938 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
939 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
940
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
941 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
942 gen_source(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
943 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
944 printf("%s",s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
945 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
946
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
947 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
948 ret(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
949 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
950 code_set_fixed_creg(1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
951 jmp(retlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
952 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
953
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
954 void
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
955 opening(char *filename)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
956 {
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
957 emit_init();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
958 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
959 code_opening(filename);
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
960 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
961
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
962 void
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
963 closing()
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
964 {
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
965 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
966 code_closing();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
967 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
968
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
969 /* end */