annotate mc-codegen.c @ 95:185d2cc6a3a9

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