annotate mc-codegen.c @ 111:7aa449aff3e6

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