annotate mc-codegen.c @ 151:81032a1b8a5d

MIPS continue
author kono
date Mon, 14 Jul 2003 14:40:35 +0900
parents cb7aa0089681
children 3edd10355434
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 */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
10
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
11 int use; /* generated value will be used */
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
12
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
13 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
14 creg currrent virtual register
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
15 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
16
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
17 static void remove0(int *parent,int e) ;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
18 /* static void remove0_all(int *parent,int e) ; */
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
19 static int is_same_type(int e1,int e2);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
20 static void jump(int e1, int env);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
21 static void machinop(int e1);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
22 static void sassign(int e1);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
23 static void assign(int e1);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
24 static void assop(int e1);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
25 static int g_expr0(int e1);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
26 static int register_to_lvar(int e);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
27
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
28 void
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
29 codegen_init()
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
30 {
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
31 code_init();
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
32 }
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
33
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
34 void
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
35 arg_register(NMTBL *fnptr)
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
36 {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
37 code_arg_register(fnptr);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
38 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
39
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
40 int
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
41 gexpr(int e1,int use0)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
42 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
43 if (chk) return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
44 gexpr_init();
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
45 use = use0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
46 #if 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
47 if(lineno==2862) {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
48 return g_expr0(e1); /*break here*/
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
49 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
50 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
51 return g_expr0(e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
52 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
53
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
54 int
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
55 g_expr_u(int e1)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
56 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
57 int t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
58 int suse = use; use=0;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
59 t=g_expr0(e1);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
60 code_gexpr(e1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
61
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
62 use=suse;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
63 return t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
64 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
65
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
66 int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
67 g_expr(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
68 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
69 int t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
70 int suse = use; use=1;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
71 t=g_expr0(e1);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
72 code_gexpr(e1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
73
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
74 use=suse;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
75 return t;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
76 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
77
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
78 int
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
79 g_expr0(int e1)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
80 {
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
81 int e2,e3,t,d;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
82 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
83
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
84 code_gexpr(e1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
85
61
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:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
89 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
90 code_gvar(e1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
91 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
92 case RGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
93 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
94 code_rgvar(e1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
95 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
96 case CRGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
97 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
98 code_crgvar(e1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
99 return CHAR;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
100 case LVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
101 creg=use_int(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
102 code_lvar(e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
103 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
104 case REGISTER:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
105 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
106 code_register(e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
107 return INT;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
108 case DREGISTER:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
109 creg=use_double(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
110 code_dregister(e2,creg,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
111 return DOUBLE;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
112 case FREGISTER:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
113 creg=use_float(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
114 code_dregister(e2,creg,0);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 135
diff changeset
115 return FLOAT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
116 case RLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
117 creg=use_int(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
118 code_rlvar(e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
119 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
120 case CRLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
121 creg=use_int(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
122 code_crlvar(e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
123 return CHAR;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
124 case FRLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
125 creg=use_float(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
126 code_drlvar(e2,0,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
127 return FLOAT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
128 case FRGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
129 creg=use_float(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
130 code_drgvar(e1,0,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
131 return FLOAT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
132 case DRLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
133 creg=use_double(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
134 code_drlvar(e2,1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
135 return DOUBLE;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
136 case DRGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
137 creg=use_double(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
138 code_drgvar(e1,1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
139 return DOUBLE;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
140 case FNAME:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
141 creg=use_int(creg);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
142 code_fname((NMTBL *)(e2),creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
143 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
144 case CONST: /* ÂåÆþ¤¹¤ëÃͤ¬0¤Ç¤âÆÃÊ̤ʽèÍý¤Ï¤·¤Ê¤¤ */
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
145 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
146 code_const(e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
147 return INT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
148 case DCONST:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
149 creg=use_double(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
150 code_dconst(e1,creg,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
151 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
152 case FCONST:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
153 creg=use_float(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
154 code_dconst(e1,creg,0);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
155 return FLOAT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
156 case STRING:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
157 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
158 code_string(e1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
159 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
160 case FUNCTION:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
161 t = function(e1);
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
162 return t;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
163 case CODE:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
164 jump(e2,caddr(e1));
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
165 return VOID;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
166 case INDIRECT:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
167 return g_expr0(e2);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
168 case RINDIRECT: case CRINDIRECT:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
169 case DRINDIRECT: case FRINDIRECT:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
170 return rindirect(e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
171 case ADDRESS:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
172 if (car(e2)==REGISTER||car(e2)==DREGISTER||car(e2)==FREGISTER)
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
173 return register_to_lvar(e2); /* too late? */
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
174 else
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
175 return g_expr0(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
176 case MINUS: /* ¥ì¥¸¥¹¥¿¤ËÂФ·¡¢negl¤ò¼Â¹Ô¤¹¤ì¤Ð¼Â¸½²Äǽ */
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
177 g_expr0(e2); code_neg(creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
178 return INT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
179 case DMINUS:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
180 g_expr0(e2); code_dneg(creg,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
181 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
182 case FMINUS:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
183 g_expr0(e2); code_dneg(creg,0);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
184 return FLOAT;
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
185 case CONV:
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
186 g_expr0(e2);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
187 switch(caddr(e1)) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
188 case I2D: code_i2d(creg); return DOUBLE;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
189 case D2I: code_d2i(creg); return INT;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
190 case U2D: code_u2d(creg); return DOUBLE;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
191 case F2U: code_f2u(creg); return UNSIGNED;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
192 case I2F: code_i2f(creg); return FLOAT;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
193 case F2I: code_f2i(creg); return INT;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
194 case U2F: code_u2f(creg); return FLOAT;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
195 case D2U: code_d2u(creg); return UNSIGNED;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
196 case D2F: code_d2f(creg); return FLOAT;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
197 case F2D: code_f2d(creg); return DOUBLE;
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
198 default:
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
199 error(-1); return INT;
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
200 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
201 case BNOT: /* ~ */
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
202 g_expr0(e2); code_not(creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
203 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
204 case LNOT: /* ! */
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
205 g_expr0(e2); code_lnot(creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
206 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
207 case PREINC:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
208 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
209 code_preinc(e1,e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
210 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
211 case POSTINC:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
212 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
213 code_postinc(e1,e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
214 return INT;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
215 case DPREINC: /* ++d */
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
216 creg=use_double(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
217 code_dpreinc(e1,e2,1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
218 return DOUBLE;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
219 case DPOSTINC: /* d++ */
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
220 creg=use_double(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
221 code_dpostinc(e1,e2,1,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
222 return DOUBLE;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
223 case FPREINC: /* ++f */
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
224 creg=use_float(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
225 code_dpreinc(e1,e2,0,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
226 return FLOAT;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
227 case FPOSTINC: /* f++ */
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
228 creg=use_float(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
229 code_dpostinc(e1,e2,0,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
230 return FLOAT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
231 case CPOSTINC:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
232 /* char *p; *p++ */
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
233 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
234 code_cpostinc(e1,e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
235 return CHAR;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
236 case CPREINC:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
237 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
238 code_cpreinc(e1,e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
239 return CHAR;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
240 case CPOSTDEC:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
241 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
242 code_cpostdec(e1,e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
243 return CHAR;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
244 case CPREDEC:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
245 creg=use_int(creg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
246 code_cpredec(e1,e2,creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
247 return CHAR;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
248 case MUL: case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
249 case DIV: case UDIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
250 case MOD: case UMOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
251 case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT:
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
252 case ADD: case SUB: case BAND: case EOR: case BOR: case CMP:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
253 creg=use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
254 machinop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
255 return INT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
256 case DMUL: case DDIV:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
257 case DADD: case DSUB:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 89
diff changeset
258 case DCMP: case DCMPGE:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
259 creg=use_double(creg);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
260 dmachinop(e1,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
261 return DOUBLE;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
262 case FMUL: case FDIV:
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
263 case FADD: case FSUB:
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
264 case FCMP: case FCMPGE:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
265 creg=use_float(creg);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
266 dmachinop(e1,0);
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
267 return FLOAT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
268 case COND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
269 e2=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
270 b_expr(cadr(e1),0,e2,0);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
271 code_set_fixed_creg(0,INT);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
272 t = g_expr0(caddr(e1));
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
273 code_set_fixed_creg(1,t);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
274 jmp(e3=fwdlabel());
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
275 fwddef(e2);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
276 code_set_fixed_creg(0,INT);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
277 t = g_expr0(cadddr(e1));
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
278 code_set_fixed_creg(1,t);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
279 fwddef(e3);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
280 return t;
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
281 case DCOND:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
282 case FCOND:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
283 d = (car(e1)==DCOND?DOUBLE:FLOAT);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
284 e2=fwdlabel();
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
285 b_expr(cadr(e1),0,e2,0);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
286 code_set_fixed_creg(0,d);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
287 t = g_expr0(caddr(e1));
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
288 code_set_fixed_creg(1,t);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
289 jmp(e3=fwdlabel());
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
290 fwddef(e2);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
291 code_set_fixed_creg(0,d);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
292 t = g_expr0(cadddr(e1));
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
293 code_set_fixed_creg(1,t);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
294 fwddef(e3);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
295 return t;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
296 case SASS:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
297 sassign(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
298 return RSTRUCT;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
299 case ASS: case CASS:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
300 assign(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
301 return INT;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
302 case FASS: case DASS: case LASS:
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
303 dassign(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
304 return DOUBLE;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
305 case ASSOP: case CASSOP:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
306 assop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
307 return INT;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
308 case DASSOP: case FASSOP:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
309 dassop(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
310 return DOUBLE;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
311 case RSTRUCT:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
312 g_expr0(e2);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
313 return RSTRUCT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
314 case COMMA:
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
315 g_expr_u(e2);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
316 return g_expr0(caddr(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
317 case RETURN:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
318 creg = use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
319 n = (NMTBL *)e2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
320 if (retcont==0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
321 retcont=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
322 code_return(creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
323 return VOID;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
324 case ENVIRONMENT:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
325 creg = use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
326 code_environment(creg);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
327 return ADDRESS;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
328 default:
116
b14ff9671c90 register offset fix
kono
parents: 111
diff changeset
329 code_bool(e1); /* type? */
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
330 return INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
331 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
332 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
333
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
334 #define dual_ops(op) \
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
335 (op==GT|| op==UGT|| op==GE|| op==UGE|| op==LT|| \
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
336 op==ULT|| op==LE|| op==ULE|| \
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
337 op==DOP+GT|| op==DOP+GE|| op==DOP+LT|| op==DOP+LE || \
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
338 op==FOP+GT|| op==FOP+GE|| op==FOP+LT|| op==FOP+LE || \
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
339 op==FOP+EQ|| op==FOP+NEQ || \
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
340 op==EQ|| op==NEQ|| op==DOP+EQ|| op==DOP+NEQ)
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
341
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
342 int
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
343 rop_dual(op)
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
344 {
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
345 if (op==GT) return LT;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
346 if (op==UGT) return ULT;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
347 if (op==GE) return LE;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
348 if (op==UGE) return ULE;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
349 if (op==LT) return GT;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
350 if (op==ULT) return UGT;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
351 if (op==LE) return GE;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
352 if (op==ULE) return UGE;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
353 if (op==DOP+GT) return DOP+LT;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
354 if (op==DOP+GE) return DOP+LE;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
355 if (op==DOP+LT) return DOP+GT;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
356 if (op==DOP+LE) return DOP+GE;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
357 if (op==FOP+GT) return FOP+LT;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
358 if (op==FOP+GE) return FOP+LE;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
359 if (op==FOP+LT) return FOP+GT;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
360 if (op==FOP+LE) return FOP+GE;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
361 return op;
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
362 }
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
363
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
364 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
365 bexpr(int e1, char cond, int l1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
366 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
367 int op = car(e1);
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
368 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
369 gexpr_init();
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
370 if (dual_ops(op) && (car(caddr(e1))==CONST||(car(caddr(e1))==DCONST)))
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
371 b_expr(list3(rop_dual(op),caddr(e1),cadr(e1)),cond,l1,0);
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
372 else
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
373 b_expr(e1,cond,l1,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
374 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
375
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
376 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
377 b_expr(int e1, char cond, int l1,int err)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
378 {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
379 int e2,l2,t;
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
380 if (!control) return;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
381 l2 = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
382 e2=cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
383 switch(car(e1)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
384 case LNOT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
385 b_expr(e2,!cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
386 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
387 case GT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
388 rexpr(e1,l1,code_gt(cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
389 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
390 case UGT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
391 rexpr(e1,l1,code_ugt(cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
392 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
393 case GE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
394 rexpr(e1,l1,code_ge(cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
395 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
396 case UGE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
397 rexpr(e1,l1,code_uge(cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
398 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
399 case LT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
400 rexpr(e1,l1,code_ge(!cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
401 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
402 case ULT:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
403 rexpr(e1,l1,code_uge(!cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
404 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
405 case LE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
406 rexpr(e1,l1,code_gt(!cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
407 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
408 case ULE:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
409 rexpr(e1,l1,code_ugt(!cond),UNSIGNED);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
410 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
411 case EQ:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
412 rexpr(e1,l1,code_eq(cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
413 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
414 case NEQ:
89
917947ffeb7c power pc version
kono
parents: 88
diff changeset
415 rexpr(e1,l1,code_eq(!cond),INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
416 return;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
417
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
418 case DOP+GT:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
419 drexpr(cadr(e1),caddr(e1),l1,DOP+GT);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
420 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
421 case DOP+GE:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
422 drexpr(cadr(e1),caddr(e1),l1,DOP+GE);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
423 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
424 case DOP+LT:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
425 drexpr(caddr(e1),cadr(e1),l1,DOP+GT);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
426 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
427 case DOP+LE:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
428 drexpr(caddr(e1),cadr(e1),l1,DOP+GE);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
429 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
430 case DOP+EQ:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
431 drexpr(cadr(e1),caddr(e1),l1,DOP+EQ);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
432 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
433 case DOP+NEQ:
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
434 drexpr(cadr(e1),caddr(e1),l1,DOP+NEQ);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
435 return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
436
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
437 case FOP+GT:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
438 drexpr(cadr(e1),caddr(e1),l1,FOP+GT);
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
439 return;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
440 case FOP+GE:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
441 drexpr(cadr(e1),caddr(e1),l1,FOP+GE);
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
442 return;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
443 case FOP+LT:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
444 drexpr(caddr(e1),cadr(e1),l1,FOP+GT);
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
445 return;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
446 case FOP+LE:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
447 drexpr(caddr(e1),cadr(e1),l1,FOP+GE);
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
448 return;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
449 case FOP+EQ:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
450 drexpr(cadr(e1),caddr(e1),l1,FOP+EQ);
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
451 return;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
452 case FOP+NEQ:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
453 drexpr(cadr(e1),caddr(e1),l1,FOP+NEQ);
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
454 return;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
455
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
456
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
457 case LAND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
458 b_expr(e2,0,cond?(l2=fwdlabel()):l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
459 b_expr(caddr(e1),cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
460 if(cond) fwddef(l2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
461 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
462 case LOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
463 b_expr(e2,1,cond?l1:(l2=fwdlabel()),0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
464 b_expr(caddr(e1),cond,l1,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
465 if(!cond) fwddef(l2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
466 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
467 case CRGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
468 creg=use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
469 code_cmp_crgvar(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
470 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
471 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
472 case CRLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
473 creg=use_int(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
474 code_cmp_crlvar(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
475 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
476 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
477 case RGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
478 creg=use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
479 code_cmp_rgvar(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
480 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
481 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
482 case RLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
483 creg=use_int(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
484 code_cmp_rlvar(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
485 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
486 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
487 case DRLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
488 creg=use_double(creg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
489 code_cmp_drlvar(e2,1);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
490 jcond(l1,cond);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
491 return;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
492 case FRLVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
493 creg=use_float(creg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
494 code_cmp_drlvar(e2,0);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
495 jcond(l1,cond);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
496 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
497 case DRGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
498 creg=use_double(creg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
499 code_cmp_drgvar(e2,1);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
500 jcond(l1,cond);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
501 return;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
502 case FRGVAR:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
503 creg=use_float(creg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
504 code_cmp_drgvar(e2,0);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
505 jcond(l1,cond);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
506 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
507 case REGISTER:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
508 creg=use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
509 code_cmp_register(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
510 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
511 return;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
512 case FREGISTER:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
513 creg=use_float(creg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
514 code_cmp_dregister(e2,0);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
515 jcond(l1,cond);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
516 return;
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
517 case DREGISTER:
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
518 creg=use_double(creg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
519 code_cmp_dregister(e2,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
520 jcond(l1,cond);
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
521 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
522 case CONST:
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
523 if(control&&((cond&&e2)||(!cond&&!e2))) jmp(l1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
524 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
525 case DCONST:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
526 case FCONST:
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
527 if(control&&((dcadr(e2)!=0.0)^cond)) jmp(l1);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
528 return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
529 default:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
530 if(err) {
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
531 error(-1); return; /* recursive g_expr/b_expr */
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
532 }
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
533 t=g_expr(e1);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
534 if(t==FLOAT)
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
535 code_cmp_dregister(creg,0);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
536 else if(t==DOUBLE)
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
537 code_cmp_dregister(creg,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
538 else
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
539 code_cmp_register(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
540 jcond(l1,cond);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
541 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
542 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
543 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
544
126
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
545 int
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
546 is_code(NMTBL *fnptr)
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
547 {
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
548 int type = fnptr->ty;
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
549 return type==CODE|| (type>0 && car(type)==CODE);
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
550 }
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
551
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
552 int
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
553 is_function(NMTBL *fnptr)
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
554 {
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
555 int type = fnptr->ty;
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
556 return type==FUNCTION || (type>0 && car(type)==FUNCTION);
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
557 }
1d1612fe705a *** empty log message ***
kono
parents: 119
diff changeset
558
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
559
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
560 static int
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
561 register_to_lvar(int e)
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
562 {
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
563 error(REG_ERR);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
564 return 0;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
565 #if 0
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
566 ÅÓÃæ¤Ç¥ì¥¸¥¹¥¿¤«¤éLVAR¤ËÊѹ¹¤·¤Æ¤â¡¢´Ö¤Ë¹ç¤ï¤Ê¤¤¡£
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
567
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
568 NMTBL *n = (NMTBL*)caddr(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
569 int reg = cadr(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
570 int tag = car(e);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
571 int lvar;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
572 int t;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
573 if (!n||n==&null_nptr) error(REG_ERR);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
574 if (tag==REGISTER) {
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
575 n->dsp = new_lvar(size_of_int);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
576 t = INT;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
577 } else if (tag==DREGISTER) {
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
578 n->dsp = new_lvar(size_of_double);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
579 t = DOUBLE;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
580 } else if (tag==FREGISTER) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
581 n->dsp = new_lvar(size_of_float);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
582 t = DOUBLE;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
583 } else error(-1);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
584 n->sc = LVAR;
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
585 lvar = list2(LVAR,n->dsp);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
586 g_expr_u(assign_expr0(list2(LVAR,n->dsp),list3(tag,reg,(int)n),t,t));
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
587 if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
588 free_register(reg);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
589 return g_expr0(lvar);
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
590 #endif
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
591 }
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
592
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
593 /* goto arguments list */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
594 /* target list4(list2(tag,disp),cdr,ty,source_expr) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
595 /* source expr=listn(tag,...) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
596 /* source (after) list2(tag,disp) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
597 /* source list list3(e,cdr,sz) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
598
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
599 #define DEBUG_PARALLEL_ASSIGN 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
600
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
601 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
602 overrap(int t,int sz,int source)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
603 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
604 int s,s0,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
605 int t0=cadr(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
606 int t1=t0+sz;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
607 for(;source;source=cadr(source)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
608 s=car(source); s0=cadr(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
609 if(car(s)==REGISTER && car(t)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
610 if(s0==t0) return s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
611 } else if (is_same_type(s,t)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
612 s1=s0+caddr(source);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
613 #if DEBUG_PARALLEL_ASSIGN>1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
614 printf("# ovedrrap source %d t0 %d t1 %d\n",car(car(t)),t0,t1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
615 printf("# ovedrrap target %d s0 %d s1 %d\n",car(car(source)),s0,s1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
616 printf("# ovedrrap equal = %d\n",((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
617 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
618 if((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)) return s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
619 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
620 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
621 return 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
622 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
623
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
624 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
625 remove_target(int *target,int t,int *use)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
626 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
627 int use0=*use;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
628 int reg;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
629 while(use0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
630 if (car(use0)==t) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
631 reg = car(caddr(use0));
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
632 if (reg==REGISTER||reg==FREGISTER||reg==DREGISTER)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
633 free_register(cadr(caddr(use0)));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
634 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
635 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
636 use0 = cadr(use0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
637 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
638 remove0(target,t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
639 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
640
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
641 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
642 save_target(int t,int s,int *target,int *use,int sz,int ty)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
643 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
644 int e1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
645 /*¿·¤·¤¤¥ì¥¸¥¹¥¿(or ¥¹¥¿¥Ã¥¯)¤ò¼èÆÀ¤¹¤ë*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
646 if (sz==size_of_int && (e1=get_register())!=-1) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
647 e1=list3(REGISTER,e1,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
648 *use=list3(t,*use,e1);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
649 g_expr_u(assign_expr0(e1,s,ty,ty));
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
650 *target = append4(*target,t,ty,e1);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
651 } else if (sz==size_of_double && (e1=get_dregister(1))!=-1) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
652 e1=list3(DREGISTER,e1,0);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
653 *use=list3(t,*use,e1);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
654 g_expr_u(assign_expr0(e1,s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
655 *target = append4(*target,t,ty,e1);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
656 } else if (sz==size_of_float && (e1=get_dregister(0))!=-1) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
657 e1=list3(FREGISTER,e1,0);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
658 *use=list3(t,*use,e1);
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
659 g_expr_u(assign_expr0(e1,s,ty,ty));
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
660 *target = append4(*target,t,ty,e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
661 } else {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
662 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
663 *target = append4(*target,t,ty,e1);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
664 *use=list3(t,*use,e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
665 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
666 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
667
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
668 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
669 circular_dependency(int t,int s,int *target,int *source)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
670 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
671 int target0=*target;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
672 int t1,sz,ty,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
673 while(target0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
674 if (cadddr(target0)==s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
675 t1=car(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
676 s=cadddr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
677 sz=size(ty=caddr(target0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
678 if(t==t1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
679 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
680 printf("# 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
681 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
682 return 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
683 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
684 if ((s1=overrap(t1,sz,*source))) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
685 /* another overrap start over */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
686 return circular_dependency(t,s1,target,source);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
687 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
688 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
689 target0=cadr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
690 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
691 return 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
692 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
693
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
694 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
695 parallel_assign(int *target,int *source,int *processing,int *use)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
696 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
697 int t,s,sz,ty,target0,s1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
698 while(*target) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
699 target0=*target;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
700 while(target0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
701 t=car(target0); s=cadddr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
702 sz=size(ty=caddr(target0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
703 if(car(t)==car(s) && cadr(t)==cadr(s)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
704 /*½ñ¤­¹þ¤ßÀ褬¼«Ê¬¼«¿È*/
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
705 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
706 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
707 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
708 remove_target(target,t,use);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
709 /* Ç˲õ¤µ¤ì¤Æ¤Ïº¤¤ë¤Î¤Ç¡¢source list¤«¤é¤Ï½ü¤«¤Ê¤¤ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
710 } else if (!(s1=overrap(t,sz,*source))) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
711 /* ½Å¤Ê¤Ã¤Æ¤Ê¤¤¤Î¤Ç°Â¿´¤·¤Æ½ñ¤­¹þ¤á¤ë */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
712 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
713 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
714 #endif
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
715 g_expr_u(assign_expr0(t,s,ty,ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
716 remove_target(target,t,use); remove0(source,s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
717 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
718 if(circular_dependency(t,s1,target,source)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
719 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
720 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
721 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
722 remove_target(target,t,use); remove0(source,s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
723 save_target(t,s,target,use,sz,ty);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
724 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
725 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
726 target0=cadr(target0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
727 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
728 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
729 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
730
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
731 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
732 remove0(int *parent,int e)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
733 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
734 int list;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
735 while ((list=*parent)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
736 if (car(list)==e) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
737 *parent= cadr(list); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
738 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
739 parent=&cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
740 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
741 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
742 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
743
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
744 /*
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
745 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
746 remove0_all(int *parent,int e)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
747 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
748 int list;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
749 while ((list=*parent)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
750 if (car(list)==e) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
751 *parent= cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
752 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
753 parent=&cadr(list);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
754 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
755 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
756 }
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
757 */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
758
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
759 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
760 is_simple(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
761 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
762 return (
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
763 e1==CONST || e1==FNAME || e1==LVAR || e1==REGISTER ||e1==DREGISTER ||
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
764 e1==FREGISTER ||
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
765 e1==GVAR || e1==RGVAR || e1==RLVAR || e1==CRLVAR || e1==CRGVAR ||
f94ca1168520 float first try...
kono
parents: 80
diff changeset
766 e1==DRLVAR || e1==FRLVAR
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
767 );
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 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
771 is_same_type(int e1,int e2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
772 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
773 int ce1=car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
774 int ce2=car(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
775 return (
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
776 (ce1==LVAR && (ce2==RLVAR||ce2==CRLVAR||ce2==FRLVAR||ce2==DRLVAR))
f94ca1168520 float first try...
kono
parents: 80
diff changeset
777 || (ce2==LVAR && (ce1==RLVAR||ce1==CRLVAR||ce1==FRLVAR||ce1==DRLVAR))
f94ca1168520 float first try...
kono
parents: 80
diff changeset
778 || (ce1==GVAR && (ce2==RGVAR||ce2==CRGVAR||ce2==FRGVAR||ce2==DRGVAR))
f94ca1168520 float first try...
kono
parents: 80
diff changeset
779 || (ce2==GVAR && (ce1==RGVAR||ce1==CRGVAR||ce1==FRGVAR||ce1==DRGVAR))
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
780 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
781 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
782
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
783 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
784 is_memory(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
785 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
786 int ce1=car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
787 return (
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
788 ce1==LVAR ||ce1==RLVAR||ce1==CRLVAR || ce1==DRLVAR ||
f94ca1168520 float first try...
kono
parents: 80
diff changeset
789 ce1==GVAR ||ce1==RGVAR||ce1==CRGVAR || ce1==DRGVAR ||
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
790 ce1==REGISTER|| ce1==DREGISTER || ce1==FREGISTER
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
791 );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
792 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
793
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
794
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
795 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
796 jump(int e1, int env)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
797 {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
798 int e2,e3,e4,sz,arg_size,ty,regs,fregs;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
799 int t0,s0,r,reg;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
800 NMTBL *code0 = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
801 int target = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
802 int source = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
803 int processing = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
804 int use = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
805
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
806 /* ¤Þ¤º¡¢¥µ¥¤¥º¤ò·×»»¤·¤Ê¤¬¤é¡¢·è¤Þ¤Ã¤¿·Á¤ËÍ¡£ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
807
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
808 arg_size = 0; regs = 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
809 fregs = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
810 for (e3 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
811 e2 = car(e3); sz = size(ty=caddr(e3));
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
812 if (scalar(ty) && (r = get_input_register_var(regs,0,1))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
813 target=list4(r,target,ty,e2); regs++;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
814 } else if (ty==FLOAT && (r = get_input_dregister_var(fregs,0,1,0))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
815 target=list4(r, target,ty,e2); fregs++;
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
816 } else if (ty==DOUBLE && (r = get_input_dregister_var(fregs,0,1,1))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
817 target=list4(r, target,ty,e2); fregs++;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
818 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
819 target=list4(list2(LVAR,0), target,ty,e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
820 }
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
821 /* keep arg space for register variables */
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
822 arg_size += sz;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
823 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
824 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
825 #endif
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 /* disp ¤òÈô¤ÓÀè»÷¹ç¤ï¤»¤Æ½¤Àµ */
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
829 if (is_code(fnptr)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
830 if (-arg_size<disp) disp = -arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
831 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
832 if (disp_offset-arg_size<disp) disp = disp_offset-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
833 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
834
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
835 /* Ê£»¨¤Ê¼°¤òÁ°¤â¤Ã¤Æ·×»»¤·¤Æ¤ª¤¯ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
836 /* ɬÍפʤé¶É½êÊÑ¿ô¤òÍѤ¤¤ë¡£ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
837 /* ¶É½êÊÑ¿ô¤Ø¤Î¥ª¥Õ¥»¥Ã¥È¤ò³Ð¤¨¤Æ¤ª¤¯ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
838
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
839 for (e2 = target; e2; e2 = cadr(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
840 t0=car(e2); s0=cadddr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
841 sz=size(ty=caddr(e2));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
842 if(car(t0)==LVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
843 /* ¤³¤³¤Ç¡¢½ñ¹þÀ襢¥É¥ì¥¹¤ò·è¤á¤ë */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
844 cadr(t0)=-arg_size;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
845 }
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
846 arg_size-=sz;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
847 if (!is_simple(car(s0))) {
94
1ad7045741a7 float dbinop fix
kono
parents: 92
diff changeset
848 g_expr_u(assign_expr0((e4=list2(LVAR,new_lvar(sz))),s0,ty,ty));
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
849 use=list3(ty,use,e1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
850 cadddr(e2)=e4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
851 s0=e4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
852 } else if (is_same_type(t0,s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
853 if(cadr(t0)==cadr(s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
854 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
855 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
856 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
857 /* we should check size also (but currently useless */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
858 remove0(&target,t0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
859 /* still we have source to avoid overwrite */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
860 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
861 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
862 if(is_memory(s0)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
863 source=list3(s0,source,sz);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
864 #if DEBUG_PARALLEL_ASSIGN
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
865 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
866 #endif
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
867 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
868 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
869
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
870 /* compute jump address */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
871 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
872 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
873 code0=(NMTBL *)cadr(e2);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
874 if (!is_code(code0)) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
875 error(TYERR); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
876 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
877 } else { /* indirect */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
878 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
879 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
880 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
881 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
882 g_expr(env);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
883 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
884 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
885
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
886 /* ÊÂÎóÂåÆþ¤ò¼Â¹Ô */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
887 parallel_assign(&target,&source,&processing,&use);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
888 while (use) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
889 reg = car(caddr(use));
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
890 if (reg==REGISTER||reg==FREGISTER||reg==DREGISTER)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
891 free_register(cadr(caddr(use)));
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
892 else if (car(caddr(use))==LVAR)
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
893 free_lvar(cadr(caddr(use)));
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
894 use=cadr(use);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
895 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
896 if(target) error(-1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
897
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
898 if (env) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
899 /* change the frame pointer */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
900 e3 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
901 code_frame_pointer(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
902 emit_pop_free(e3);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
903 } else if (is_function(fnptr)) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
904 if (car(e2) != FNAME) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
905 e2 = emit_pop(0);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
906 code_fix_frame_pointer(disp_offset);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
907 code_indirect_jmp(e2);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
908 emit_pop_free(e2);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
909 return;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
910 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
911 code_fix_frame_pointer(disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
912 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
913
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
914 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
915 code_jmp(code0->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
916 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
917 e2 = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
918 code_indirect_jmp(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
919 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
920 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
921 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
922
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
923 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
924 machinop(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
925 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
926 int e2,e3,op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
927
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
928 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
929 op = car(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
930 e3 = caddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
931 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
932 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
933 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
934 tosop(car(e1),(e2=pop_register()));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
935 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
936 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
937 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
938
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
939 void
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
940 dmachinop(int e1,int d)
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
941 {
f94ca1168520 float first try...
kono
parents: 80
diff changeset
942 int e2,e3,op;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
943
f94ca1168520 float first try...
kono
parents: 80
diff changeset
944 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
945 op = car(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
946 e3 = caddr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
947 g_expr(e3);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
948 emit_dpush(d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
949 g_expr(e2);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
950 dtosop(car(e1),(e2=emit_dpop(d)));
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
951 emit_dpop_free(e2,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
952 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
953 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
954
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
955 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
956 sassign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
957 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
958 int e2,e3,e4,sz,xreg,det;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
959
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
960 /* structure assignment */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
961 e2 = cadr(e1); /* pointer variable to the struct */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
962 e3 = cadr(e2); /* offset of the variable (distination) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
963 e4 = caddr(e1); /* right value (source) */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
964 sz = cadddr(e1); /* size of struct or union */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
965 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
966 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
967 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
968 xreg = emit_pop(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
969 /* °ìÈÌŪ¤Ë¤Ï¥³¥Ô¡¼¤Î¥ª¡¼¥Ð¥é¥Ã¥×¤Î¾õ¶·¤Ï¼Â¹Ô»þ¤Ë¤·¤«¤ï¤«¤é¤Ê¤¤ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
970 /* ¤·¤«¤·¡¢¤ï¤«¤ë¾ì¹ç¤â¤¢¤ë */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
971 if (car(e4)==RSTRUCT) e4=cadr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
972 if (is_same_type(e2,e4)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
973 if(cadr(e2)<cadr(e4)) sz=-sz;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
974 det=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
975 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
976 det = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
977 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
978 emit_copy(xreg,creg,sz,0,1,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
979 emit_pop_free(xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
980 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
981 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
982
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
983 void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
984 assign_opt(int e5,int e2,int e4,int byte)
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
985 {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
986 int reg;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
987 /* e2=e4 */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
988 if (e5==REGISTER) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
989 reg = cadr(e4);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
990 switch(car(e2)) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
991 case GVAR: code_assign_gvar(e2,reg,byte); return;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
992 case LVAR: code_assign_lvar(cadr(e2),reg,byte); return;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
993 case REGISTER: code_assign_register(cadr(e2),byte,reg); return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
994 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
995 g_expr(e2);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
996 code_assign(e2,byte,reg);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
997 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
998 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
999 /* e2 is register now */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1000 if (car(e2)!=REGISTER) error(-1);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1001 reg = cadr(e2);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1002 switch(e5) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1003 case CRGVAR: code_crgvar(e4,reg); return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1004 case RGVAR: code_rgvar(e4,reg); return;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1005 case CRLVAR: code_crlvar(cadr(e4),reg); return;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1006 case RLVAR: code_rlvar(cadr(e4),reg); return;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1007 case GVAR: code_gvar(e4,reg); return;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1008 case LVAR: code_lvar(cadr(e4),reg); return;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1009 case CONST: code_const(cadr(e4),reg); return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1010 case ADDRESS:
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1011 if (car(cadr(e4))==STRING) code_string(cadr(e4),reg);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1012 else code_gvar(cadr(e4),reg);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1013 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1014 case FNAME: code_fname((NMTBL*)cadr(e4),reg); return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1015 case STRING: code_string(e4,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1016 default: error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1017 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1018 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1019
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1020 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1021 assign(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1022 {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1023 int e2,e4,byte,e5;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1024
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1025 byte=(car(e1) == CASS);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1026 /* e2=e4 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1027 e2 = cadr(e1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1028 e4 = caddr(e1);e5=car(e4);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1029 if (!use && (
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1030 (e5==REGISTER) ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1031 (car(e2)==REGISTER&&(
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1032 e5== CRGVAR || e5== CRLVAR || e5== RGVAR || e5== RLVAR ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1033 e5== GVAR || e5== LVAR ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1034 e5== CONST || e5== FNAME || e5== STRING ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1035 (e5==ADDRESS&&car(cadr(e4))==STRING) ||
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1036 (e5==ADDRESS&&car(cadr(e4))==GVAR) )))) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1037 creg = use_int(creg);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1038 assign_opt(e5,e2,e4,byte);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1039 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1040 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1041 switch(car(e2)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1042 case GVAR: /* i=3 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1043 g_expr(e4);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1044 code_assign_gvar(e2,creg,byte);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1045 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1046 case LVAR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1047 g_expr(e4);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1048 code_assign_lvar(cadr(e2),creg,byte);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1049 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1050 case REGISTER:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1051 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1052 if (creg!=cadr(e2))
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1053 code_assign_register(cadr(e2),byte,creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1054 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1055 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1056 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1057 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1058 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1059 e2 = emit_pop(0);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1060 code_assign(e2,byte,creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1061 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1062 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1063 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1064
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1065 void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1066 dassign_opt(int e5,int e2,int e4,int d)
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1067 {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1068 int reg;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1069 /* e2=e4 */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1070 if (e5==DREGISTER||e5==FREGISTER) {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1071 reg = cadr(e4);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1072 switch(car(e2)) {
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1073 case GVAR: /* i=3 */
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1074 code_dassign_gvar(e2,reg,d);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1075 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1076 case LVAR:
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1077 code_dassign_lvar(cadr(e2),reg,d);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1078 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1079 case DREGISTER:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1080 case FREGISTER:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1081 if (reg!=cadr(e2))
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1082 code_dassign_dregister(cadr(e2),d,reg);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1083 return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1084 default:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1085 error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1086 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1087 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1088 /* e2 is register now */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1089 if (car(e2)!=DREGISTER && car(e2)!=FREGISTER) error(-1);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1090 reg = cadr(e2);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1091 switch(e5) {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1092 case FRGVAR:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1093 case DRGVAR: code_drgvar(e4,d,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1094 case FRLVAR:
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1095 case DRLVAR: code_drlvar(cadr(e4),d,reg); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1096 case FCONST:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1097 case DCONST: code_dconst(e4,reg,1); return;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1098 default:
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1099 error(-1);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1100 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1101 }
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1102
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1103 void
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1104 dassign(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1105 {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1106 int e2,e3,e4,d,e5;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1107
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1108 /* e2=e4 */
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1109 e2 = cadr(e1);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1110 e3 = cadr(e2);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1111 e4 = caddr(e1); e5=car(e4);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1112 d = (car(e1)==LASS)?2:(car(e1)==DASS)?1:0;
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1113 if (!use && (
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1114 (e5==DREGISTER) || (e5==FREGISTER) ||
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1115 (car(e2)==DREGISTER&&(e5==DRGVAR||e5==DRLVAR||e5==DCONST))||
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1116 (car(e2)==DREGISTER&&(e5==FRGVAR||e5==FRLVAR||e5==FCONST))
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1117 )) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1118 creg = d?use_double(creg):use_float(creg);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1119 dassign_opt(e5,e2,e4,d);
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1120 return;
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1121 }
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1122 switch(car(e2)) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1123 case GVAR:
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1124 g_expr(e4);
151
81032a1b8a5d MIPS continue
kono
parents: 147
diff changeset
1125 creg = d?use_double(creg):use_float(creg);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1126 code_dassign_gvar(e2,creg,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1127 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1128 case LVAR:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1129 g_expr(e4);
151
81032a1b8a5d MIPS continue
kono
parents: 147
diff changeset
1130 creg = d?use_double(creg):use_float(creg);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1131 code_dassign_lvar(cadr(e2),creg,d);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1132 return;
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1133 case DREGISTER:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1134 case FREGISTER:
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1135 g_expr(e4);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1136 if (creg!=cadr(e2)) {
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1137 if (d) creg = use_double(creg); else creg = use_float(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1138 code_dassign_dregister(cadr(e2),d,creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1139 }
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1140 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1141 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1142 g_expr(e2);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1143 emit_push();
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1144 g_expr(e4);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1145 e2 = emit_pop(0);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1146 code_dassign(e2,creg,d);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1147 emit_pop_free(e2);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1148 return;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1149 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1150
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1151 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1152 assop(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1153 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1154 int e2,e3,byte,op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1155
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1156 /* e2 op= e3 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1157 byte = (car(e1) == CASSOP);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1158 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1159 if (car(e2)==INDIRECT) e2=cadr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1160 e3 = caddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1161 op = cadddr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1162
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1163 creg = use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1164 g_expr(e3);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1165 if (car(e2)==REGISTER) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1166 code_register_assop(cadr(e2),op,byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1167 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1168 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1169 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1170 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1171 code_assop(op,byte);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1172 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1173 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1174
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1175 void
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1176 dassop(int e1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1177 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1178 int e2,e3,op,d;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1179
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1180 /* e2 op= e3 */
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1181 d = (car(e1) == DASSOP);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1182 e2 = cadr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1183 if (car(e2)==INDIRECT) e2=cadr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1184 e3 = caddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1185 op = cadddr(e1);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1186
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1187 creg = d?use_double(creg):use_float(creg);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1188 g_expr(e3);
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1189 emit_dpush(d);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1190 g_expr(e2);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1191 if (car(e2)==DREGISTER||car(e2)==FREGISTER) {
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1192 /* code_register_dassop(cadr(e2),op,d); */
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1193 error(-1); /* unsupported now */
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1194 return;
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1195 }
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1196 code_dassop(op,d);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1197 return;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
1198 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1199
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1200 void
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1201 cmpdimm(int e, int csreg)
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1202 {
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1203 code_cmpdimm(e, csreg);
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1204 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1205
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1206 int
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1207 csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1208 {
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1209 return code_csvalue();
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1210 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1211
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1212
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1213 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1214 fwdlabel(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1215 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1216 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1217 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1218
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1219 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1220 fwddef(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1221 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1222 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1223 if (!chk)
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1224 code_label(l);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1225 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1226
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1227 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1228 backdef(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1229 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1230 control=1;
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1231 if (!chk)
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
1232 code_label(labelno);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1233 return labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1234 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1235
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1236 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1237 def_label(int cslabel, int dlabel)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1238 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1239 int fl;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1240
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1241 fl = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1242 if (control) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1243 jmp(fl=fwdlabel());
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1244 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1245 fwddef(cslabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1246 if (dlabel)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1247 jmp(dlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1248 if (fl) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1249 fwddef(fl);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1250 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1251 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1252
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1253 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1254 gen_source(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1255 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1256 printf("%s",s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1257 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1258
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1259 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1260 ret(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1261 {
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1262 code_set_return_register(1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1263 jmp(retlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1264 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1265
66
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1266 void
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1267 opening(char *filename)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1268 {
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1269 emit_init();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1270 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1271 code_opening(filename);
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1272 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1273
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1274 void
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1275 closing()
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1276 {
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1277 if (!chk)
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1278 code_closing();
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1279 }
0b068058dd67 *** empty log message ***
kono
parents: 61
diff changeset
1280
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1281 int
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1282 contains_in_list(int e,int type)
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1283 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1284 while(e) {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1285 if(contains(car(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1286 e = cadr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1287 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1288 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1289 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1290
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1291 int
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1292 contains(int e,int type)
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1293 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1294 while(e) {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1295 if (car(e)==type) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1296 switch (car(e)){
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1297 /* list arguments */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1298 case FUNCTION: case CODE:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1299 return contains_in_list(caddr(e),type);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1300 /* unary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1301 case INDIRECT: case RINDIRECT: case CRINDIRECT:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1302 case DRINDIRECT: case FRINDIRECT: case ADDRESS: case MINUS: case DMINUS:
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1303 case BNOT: case LNOT:
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1304 case PREINC: case POSTINC: case DPREINC: case DPOSTINC:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1305 case FPREINC: case FPOSTINC: case CPOSTINC:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1306 case CPREINC: case CPOSTDEC: case CPREDEC:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1307 case RSTRUCT:
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1308 /* case I2D: case D2I: case U2D: case D2U: */
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1309 case CONV:
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1310 e = cadr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1311 continue;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1312 /* biary operators */
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1313 case MUL: case UMUL: case DIV: case UDIV: case MOD: case UMOD:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1314 case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1315 case ADD: case SUB: case BAND: case EOR: case BOR: case CMP:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1316 case DMUL: case DDIV: case DADD: case DSUB: case DCMP: case DCMPGE:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1317 case FMUL: case FDIV: case FADD: case FSUB: case FCMP: case FCMPGE:
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1318 case SASS: case ASS: case CASS: case FASS: case DASS: case LASS:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1319 case ASSOP: case CASSOP: case DASSOP: case FASSOP: case COMMA:
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1320 case EQ: case NEQ:
151
81032a1b8a5d MIPS continue
kono
parents: 147
diff changeset
1321 case LAND: case LOR:
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1322 case DOP+EQ: case DOP+NEQ:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1323 case FOP+EQ: case FOP+NEQ:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1324 case LT: case ULT: case LE: case ULE:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1325 case GT: case UGT: case GE: case UGE:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1326 case DOP+LT: case DOP+LE: case DOP+GT: case DOP+GE:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1327 case FOP+LT: case FOP+LE: case FOP+GT: case FOP+GE:
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1328 if (contains(cadr(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1329 e = caddr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1330 continue;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1331 /* tarary operators */
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
1332 case COND: case DCOND: case FCOND:
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1333 if (contains(cadr(e), type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1334 if (contains(caddr(e),type)) return 1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1335 e = cadddr(e);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1336 continue;
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1337 /* nullary operators */
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1338 case GVAR: case RGVAR: case CRGVAR: case LVAR:
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1339 case REGISTER: case DREGISTER: case FREGISTER:
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1340 case RLVAR: case CRLVAR: case FRLVAR: case FRGVAR:
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1341 case DRLVAR: case DRGVAR:
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1342 case FNAME: case CONST: case DCONST: case FCONST: case STRING:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1343 case RETURN: case ENVIRONMENT:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1344 return 0;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1345 default:
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1346 fprintf(stderr,"Unknown Tree ID %d\n",car(e));
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
1347 error(-1);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1348 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1349 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1350 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1351 return 0;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1352 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1353
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1354 /* end */