Revision 07d2c595 target-i386/helper_template.h
b/target-i386/helper_template.h | ||
---|---|---|
50 | 50 |
#error unhandled operand size |
51 | 51 |
#endif |
52 | 52 |
|
53 |
/* dynamic flags computation */ |
|
54 |
|
|
55 |
static int glue(compute_all_add, SUFFIX)(void) |
|
56 |
{ |
|
57 |
int cf, pf, af, zf, sf, of; |
|
58 |
target_long src1, src2; |
|
59 |
src1 = CC_SRC; |
|
60 |
src2 = CC_DST - CC_SRC; |
|
61 |
cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1; |
|
62 |
pf = parity_table[(uint8_t)CC_DST]; |
|
63 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
64 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
65 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
66 |
of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
67 |
return cf | pf | af | zf | sf | of; |
|
68 |
} |
|
69 |
|
|
70 |
static int glue(compute_c_add, SUFFIX)(void) |
|
71 |
{ |
|
72 |
int cf; |
|
73 |
target_long src1; |
|
74 |
src1 = CC_SRC; |
|
75 |
cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1; |
|
76 |
return cf; |
|
77 |
} |
|
78 |
|
|
79 |
static int glue(compute_all_adc, SUFFIX)(void) |
|
80 |
{ |
|
81 |
int cf, pf, af, zf, sf, of; |
|
82 |
target_long src1, src2; |
|
83 |
src1 = CC_SRC; |
|
84 |
src2 = CC_DST - CC_SRC - 1; |
|
85 |
cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1; |
|
86 |
pf = parity_table[(uint8_t)CC_DST]; |
|
87 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
88 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
89 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
90 |
of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
91 |
return cf | pf | af | zf | sf | of; |
|
92 |
} |
|
93 |
|
|
94 |
static int glue(compute_c_adc, SUFFIX)(void) |
|
95 |
{ |
|
96 |
int cf; |
|
97 |
target_long src1; |
|
98 |
src1 = CC_SRC; |
|
99 |
cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1; |
|
100 |
return cf; |
|
101 |
} |
|
102 |
|
|
103 |
static int glue(compute_all_sub, SUFFIX)(void) |
|
104 |
{ |
|
105 |
int cf, pf, af, zf, sf, of; |
|
106 |
target_long src1, src2; |
|
107 |
src1 = CC_DST + CC_SRC; |
|
108 |
src2 = CC_SRC; |
|
109 |
cf = (DATA_TYPE)src1 < (DATA_TYPE)src2; |
|
110 |
pf = parity_table[(uint8_t)CC_DST]; |
|
111 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
112 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
113 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
114 |
of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
115 |
return cf | pf | af | zf | sf | of; |
|
116 |
} |
|
117 |
|
|
118 |
static int glue(compute_c_sub, SUFFIX)(void) |
|
119 |
{ |
|
120 |
int cf; |
|
121 |
target_long src1, src2; |
|
122 |
src1 = CC_DST + CC_SRC; |
|
123 |
src2 = CC_SRC; |
|
124 |
cf = (DATA_TYPE)src1 < (DATA_TYPE)src2; |
|
125 |
return cf; |
|
126 |
} |
|
127 |
|
|
128 |
static int glue(compute_all_sbb, SUFFIX)(void) |
|
129 |
{ |
|
130 |
int cf, pf, af, zf, sf, of; |
|
131 |
target_long src1, src2; |
|
132 |
src1 = CC_DST + CC_SRC + 1; |
|
133 |
src2 = CC_SRC; |
|
134 |
cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2; |
|
135 |
pf = parity_table[(uint8_t)CC_DST]; |
|
136 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
137 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
138 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
139 |
of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
140 |
return cf | pf | af | zf | sf | of; |
|
141 |
} |
|
142 |
|
|
143 |
static int glue(compute_c_sbb, SUFFIX)(void) |
|
144 |
{ |
|
145 |
int cf; |
|
146 |
target_long src1, src2; |
|
147 |
src1 = CC_DST + CC_SRC + 1; |
|
148 |
src2 = CC_SRC; |
|
149 |
cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2; |
|
150 |
return cf; |
|
151 |
} |
|
152 |
|
|
153 |
static int glue(compute_all_logic, SUFFIX)(void) |
|
154 |
{ |
|
155 |
int cf, pf, af, zf, sf, of; |
|
156 |
cf = 0; |
|
157 |
pf = parity_table[(uint8_t)CC_DST]; |
|
158 |
af = 0; |
|
159 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
160 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
161 |
of = 0; |
|
162 |
return cf | pf | af | zf | sf | of; |
|
163 |
} |
|
164 |
|
|
165 |
static int glue(compute_c_logic, SUFFIX)(void) |
|
166 |
{ |
|
167 |
return 0; |
|
168 |
} |
|
169 |
|
|
170 |
static int glue(compute_all_inc, SUFFIX)(void) |
|
171 |
{ |
|
172 |
int cf, pf, af, zf, sf, of; |
|
173 |
target_long src1, src2; |
|
174 |
src1 = CC_DST - 1; |
|
175 |
src2 = 1; |
|
176 |
cf = CC_SRC; |
|
177 |
pf = parity_table[(uint8_t)CC_DST]; |
|
178 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
179 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
180 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
181 |
of = ((CC_DST & DATA_MASK) == SIGN_MASK) << 11; |
|
182 |
return cf | pf | af | zf | sf | of; |
|
183 |
} |
|
184 |
|
|
185 |
#if DATA_BITS == 32 |
|
186 |
static int glue(compute_c_inc, SUFFIX)(void) |
|
187 |
{ |
|
188 |
return CC_SRC; |
|
189 |
} |
|
190 |
#endif |
|
191 |
|
|
192 |
static int glue(compute_all_dec, SUFFIX)(void) |
|
193 |
{ |
|
194 |
int cf, pf, af, zf, sf, of; |
|
195 |
target_long src1, src2; |
|
196 |
src1 = CC_DST + 1; |
|
197 |
src2 = 1; |
|
198 |
cf = CC_SRC; |
|
199 |
pf = parity_table[(uint8_t)CC_DST]; |
|
200 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
201 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
202 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
203 |
of = ((CC_DST & DATA_MASK) == ((target_ulong)SIGN_MASK - 1)) << 11; |
|
204 |
return cf | pf | af | zf | sf | of; |
|
205 |
} |
|
206 |
|
|
207 |
static int glue(compute_all_shl, SUFFIX)(void) |
|
208 |
{ |
|
209 |
int cf, pf, af, zf, sf, of; |
|
210 |
cf = (CC_SRC >> (DATA_BITS - 1)) & CC_C; |
|
211 |
pf = parity_table[(uint8_t)CC_DST]; |
|
212 |
af = 0; /* undefined */ |
|
213 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
214 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
215 |
/* of is defined if shift count == 1 */ |
|
216 |
of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O; |
|
217 |
return cf | pf | af | zf | sf | of; |
|
218 |
} |
|
219 |
|
|
220 |
static int glue(compute_c_shl, SUFFIX)(void) |
|
221 |
{ |
|
222 |
return (CC_SRC >> (DATA_BITS - 1)) & CC_C; |
|
223 |
} |
|
224 |
|
|
225 |
#if DATA_BITS == 32 |
|
226 |
static int glue(compute_c_sar, SUFFIX)(void) |
|
227 |
{ |
|
228 |
return CC_SRC & 1; |
|
229 |
} |
|
230 |
#endif |
|
231 |
|
|
232 |
static int glue(compute_all_sar, SUFFIX)(void) |
|
233 |
{ |
|
234 |
int cf, pf, af, zf, sf, of; |
|
235 |
cf = CC_SRC & 1; |
|
236 |
pf = parity_table[(uint8_t)CC_DST]; |
|
237 |
af = 0; /* undefined */ |
|
238 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
239 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
240 |
/* of is defined if shift count == 1 */ |
|
241 |
of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O; |
|
242 |
return cf | pf | af | zf | sf | of; |
|
243 |
} |
|
244 |
|
|
245 |
#if DATA_BITS == 32 |
|
246 |
static int glue(compute_c_mul, SUFFIX)(void) |
|
247 |
{ |
|
248 |
int cf; |
|
249 |
cf = (CC_SRC != 0); |
|
250 |
return cf; |
|
251 |
} |
|
252 |
#endif |
|
253 |
|
|
254 |
/* NOTE: we compute the flags like the P4. On olders CPUs, only OF and |
|
255 |
CF are modified and it is slower to do that. */ |
|
256 |
static int glue(compute_all_mul, SUFFIX)(void) |
|
257 |
{ |
|
258 |
int cf, pf, af, zf, sf, of; |
|
259 |
cf = (CC_SRC != 0); |
|
260 |
pf = parity_table[(uint8_t)CC_DST]; |
|
261 |
af = 0; /* undefined */ |
|
262 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
263 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
264 |
of = cf << 11; |
|
265 |
return cf | pf | af | zf | sf | of; |
|
266 |
} |
|
267 |
|
|
268 |
/* shifts */ |
|
269 |
|
|
53 | 270 |
target_ulong glue(helper_rcl, SUFFIX)(target_ulong t0, target_ulong t1) |
54 | 271 |
{ |
55 | 272 |
int count, eflags; |
Also available in: Unified diff