Revision 07d2c595
b/target-i386/helper.c | ||
---|---|---|
5239 | 5239 |
#undef SHIFT |
5240 | 5240 |
|
5241 | 5241 |
#endif |
5242 |
|
|
5243 |
static int compute_all_eflags(void) |
|
5244 |
{ |
|
5245 |
return CC_SRC; |
|
5246 |
} |
|
5247 |
|
|
5248 |
static int compute_c_eflags(void) |
|
5249 |
{ |
|
5250 |
return CC_SRC & CC_C; |
|
5251 |
} |
|
5252 |
|
|
5253 |
CCTable cc_table[CC_OP_NB] = { |
|
5254 |
[CC_OP_DYNAMIC] = { /* should never happen */ }, |
|
5255 |
|
|
5256 |
[CC_OP_EFLAGS] = { compute_all_eflags, compute_c_eflags }, |
|
5257 |
|
|
5258 |
[CC_OP_MULB] = { compute_all_mulb, compute_c_mull }, |
|
5259 |
[CC_OP_MULW] = { compute_all_mulw, compute_c_mull }, |
|
5260 |
[CC_OP_MULL] = { compute_all_mull, compute_c_mull }, |
|
5261 |
|
|
5262 |
[CC_OP_ADDB] = { compute_all_addb, compute_c_addb }, |
|
5263 |
[CC_OP_ADDW] = { compute_all_addw, compute_c_addw }, |
|
5264 |
[CC_OP_ADDL] = { compute_all_addl, compute_c_addl }, |
|
5265 |
|
|
5266 |
[CC_OP_ADCB] = { compute_all_adcb, compute_c_adcb }, |
|
5267 |
[CC_OP_ADCW] = { compute_all_adcw, compute_c_adcw }, |
|
5268 |
[CC_OP_ADCL] = { compute_all_adcl, compute_c_adcl }, |
|
5269 |
|
|
5270 |
[CC_OP_SUBB] = { compute_all_subb, compute_c_subb }, |
|
5271 |
[CC_OP_SUBW] = { compute_all_subw, compute_c_subw }, |
|
5272 |
[CC_OP_SUBL] = { compute_all_subl, compute_c_subl }, |
|
5273 |
|
|
5274 |
[CC_OP_SBBB] = { compute_all_sbbb, compute_c_sbbb }, |
|
5275 |
[CC_OP_SBBW] = { compute_all_sbbw, compute_c_sbbw }, |
|
5276 |
[CC_OP_SBBL] = { compute_all_sbbl, compute_c_sbbl }, |
|
5277 |
|
|
5278 |
[CC_OP_LOGICB] = { compute_all_logicb, compute_c_logicb }, |
|
5279 |
[CC_OP_LOGICW] = { compute_all_logicw, compute_c_logicw }, |
|
5280 |
[CC_OP_LOGICL] = { compute_all_logicl, compute_c_logicl }, |
|
5281 |
|
|
5282 |
[CC_OP_INCB] = { compute_all_incb, compute_c_incl }, |
|
5283 |
[CC_OP_INCW] = { compute_all_incw, compute_c_incl }, |
|
5284 |
[CC_OP_INCL] = { compute_all_incl, compute_c_incl }, |
|
5285 |
|
|
5286 |
[CC_OP_DECB] = { compute_all_decb, compute_c_incl }, |
|
5287 |
[CC_OP_DECW] = { compute_all_decw, compute_c_incl }, |
|
5288 |
[CC_OP_DECL] = { compute_all_decl, compute_c_incl }, |
|
5289 |
|
|
5290 |
[CC_OP_SHLB] = { compute_all_shlb, compute_c_shlb }, |
|
5291 |
[CC_OP_SHLW] = { compute_all_shlw, compute_c_shlw }, |
|
5292 |
[CC_OP_SHLL] = { compute_all_shll, compute_c_shll }, |
|
5293 |
|
|
5294 |
[CC_OP_SARB] = { compute_all_sarb, compute_c_sarl }, |
|
5295 |
[CC_OP_SARW] = { compute_all_sarw, compute_c_sarl }, |
|
5296 |
[CC_OP_SARL] = { compute_all_sarl, compute_c_sarl }, |
|
5297 |
|
|
5298 |
#ifdef TARGET_X86_64 |
|
5299 |
[CC_OP_MULQ] = { compute_all_mulq, compute_c_mull }, |
|
5300 |
|
|
5301 |
[CC_OP_ADDQ] = { compute_all_addq, compute_c_addq }, |
|
5302 |
|
|
5303 |
[CC_OP_ADCQ] = { compute_all_adcq, compute_c_adcq }, |
|
5304 |
|
|
5305 |
[CC_OP_SUBQ] = { compute_all_subq, compute_c_subq }, |
|
5306 |
|
|
5307 |
[CC_OP_SBBQ] = { compute_all_sbbq, compute_c_sbbq }, |
|
5308 |
|
|
5309 |
[CC_OP_LOGICQ] = { compute_all_logicq, compute_c_logicq }, |
|
5310 |
|
|
5311 |
[CC_OP_INCQ] = { compute_all_incq, compute_c_incl }, |
|
5312 |
|
|
5313 |
[CC_OP_DECQ] = { compute_all_decq, compute_c_incl }, |
|
5314 |
|
|
5315 |
[CC_OP_SHLQ] = { compute_all_shlq, compute_c_shlq }, |
|
5316 |
|
|
5317 |
[CC_OP_SARQ] = { compute_all_sarq, compute_c_sarl }, |
|
5318 |
#endif |
|
5319 |
}; |
|
5320 |
|
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; |
b/target-i386/op.c | ||
---|---|---|
752 | 752 |
EAX = (EAX & ~0xff) | ((-cf) & 0xff); |
753 | 753 |
} |
754 | 754 |
|
755 |
static int compute_all_eflags(void) |
|
756 |
{ |
|
757 |
return CC_SRC; |
|
758 |
} |
|
759 |
|
|
760 |
static int compute_c_eflags(void) |
|
761 |
{ |
|
762 |
return CC_SRC & CC_C; |
|
763 |
} |
|
764 |
|
|
765 |
CCTable cc_table[CC_OP_NB] = { |
|
766 |
[CC_OP_DYNAMIC] = { /* should never happen */ }, |
|
767 |
|
|
768 |
[CC_OP_EFLAGS] = { compute_all_eflags, compute_c_eflags }, |
|
769 |
|
|
770 |
[CC_OP_MULB] = { compute_all_mulb, compute_c_mull }, |
|
771 |
[CC_OP_MULW] = { compute_all_mulw, compute_c_mull }, |
|
772 |
[CC_OP_MULL] = { compute_all_mull, compute_c_mull }, |
|
773 |
|
|
774 |
[CC_OP_ADDB] = { compute_all_addb, compute_c_addb }, |
|
775 |
[CC_OP_ADDW] = { compute_all_addw, compute_c_addw }, |
|
776 |
[CC_OP_ADDL] = { compute_all_addl, compute_c_addl }, |
|
777 |
|
|
778 |
[CC_OP_ADCB] = { compute_all_adcb, compute_c_adcb }, |
|
779 |
[CC_OP_ADCW] = { compute_all_adcw, compute_c_adcw }, |
|
780 |
[CC_OP_ADCL] = { compute_all_adcl, compute_c_adcl }, |
|
781 |
|
|
782 |
[CC_OP_SUBB] = { compute_all_subb, compute_c_subb }, |
|
783 |
[CC_OP_SUBW] = { compute_all_subw, compute_c_subw }, |
|
784 |
[CC_OP_SUBL] = { compute_all_subl, compute_c_subl }, |
|
785 |
|
|
786 |
[CC_OP_SBBB] = { compute_all_sbbb, compute_c_sbbb }, |
|
787 |
[CC_OP_SBBW] = { compute_all_sbbw, compute_c_sbbw }, |
|
788 |
[CC_OP_SBBL] = { compute_all_sbbl, compute_c_sbbl }, |
|
789 |
|
|
790 |
[CC_OP_LOGICB] = { compute_all_logicb, compute_c_logicb }, |
|
791 |
[CC_OP_LOGICW] = { compute_all_logicw, compute_c_logicw }, |
|
792 |
[CC_OP_LOGICL] = { compute_all_logicl, compute_c_logicl }, |
|
793 |
|
|
794 |
[CC_OP_INCB] = { compute_all_incb, compute_c_incl }, |
|
795 |
[CC_OP_INCW] = { compute_all_incw, compute_c_incl }, |
|
796 |
[CC_OP_INCL] = { compute_all_incl, compute_c_incl }, |
|
797 |
|
|
798 |
[CC_OP_DECB] = { compute_all_decb, compute_c_incl }, |
|
799 |
[CC_OP_DECW] = { compute_all_decw, compute_c_incl }, |
|
800 |
[CC_OP_DECL] = { compute_all_decl, compute_c_incl }, |
|
801 |
|
|
802 |
[CC_OP_SHLB] = { compute_all_shlb, compute_c_shlb }, |
|
803 |
[CC_OP_SHLW] = { compute_all_shlw, compute_c_shlw }, |
|
804 |
[CC_OP_SHLL] = { compute_all_shll, compute_c_shll }, |
|
805 |
|
|
806 |
[CC_OP_SARB] = { compute_all_sarb, compute_c_sarl }, |
|
807 |
[CC_OP_SARW] = { compute_all_sarw, compute_c_sarl }, |
|
808 |
[CC_OP_SARL] = { compute_all_sarl, compute_c_sarl }, |
|
809 |
|
|
810 |
#ifdef TARGET_X86_64 |
|
811 |
[CC_OP_MULQ] = { compute_all_mulq, compute_c_mull }, |
|
812 |
|
|
813 |
[CC_OP_ADDQ] = { compute_all_addq, compute_c_addq }, |
|
814 |
|
|
815 |
[CC_OP_ADCQ] = { compute_all_adcq, compute_c_adcq }, |
|
816 |
|
|
817 |
[CC_OP_SUBQ] = { compute_all_subq, compute_c_subq }, |
|
818 |
|
|
819 |
[CC_OP_SBBQ] = { compute_all_sbbq, compute_c_sbbq }, |
|
820 |
|
|
821 |
[CC_OP_LOGICQ] = { compute_all_logicq, compute_c_logicq }, |
|
822 |
|
|
823 |
[CC_OP_INCQ] = { compute_all_incq, compute_c_incl }, |
|
824 |
|
|
825 |
[CC_OP_DECQ] = { compute_all_decq, compute_c_incl }, |
|
826 |
|
|
827 |
[CC_OP_SHLQ] = { compute_all_shlq, compute_c_shlq }, |
|
828 |
|
|
829 |
[CC_OP_SARQ] = { compute_all_sarq, compute_c_sarl }, |
|
830 |
#endif |
|
831 |
}; |
|
832 |
|
|
833 | 755 |
void OPPROTO op_fcomi_dummy(void) |
834 | 756 |
{ |
835 | 757 |
T0 = 0; |
b/target-i386/ops_template.h | ||
---|---|---|
51 | 51 |
#error unhandled operand size |
52 | 52 |
#endif |
53 | 53 |
|
54 |
/* dynamic flags computation */ |
|
55 |
|
|
56 |
static int glue(compute_all_add, SUFFIX)(void) |
|
57 |
{ |
|
58 |
int cf, pf, af, zf, sf, of; |
|
59 |
target_long src1, src2; |
|
60 |
src1 = CC_SRC; |
|
61 |
src2 = CC_DST - CC_SRC; |
|
62 |
cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1; |
|
63 |
pf = parity_table[(uint8_t)CC_DST]; |
|
64 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
65 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
66 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
67 |
of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
68 |
return cf | pf | af | zf | sf | of; |
|
69 |
} |
|
70 |
|
|
71 |
static int glue(compute_c_add, SUFFIX)(void) |
|
72 |
{ |
|
73 |
int cf; |
|
74 |
target_long src1; |
|
75 |
src1 = CC_SRC; |
|
76 |
cf = (DATA_TYPE)CC_DST < (DATA_TYPE)src1; |
|
77 |
return cf; |
|
78 |
} |
|
79 |
|
|
80 |
static int glue(compute_all_adc, SUFFIX)(void) |
|
81 |
{ |
|
82 |
int cf, pf, af, zf, sf, of; |
|
83 |
target_long src1, src2; |
|
84 |
src1 = CC_SRC; |
|
85 |
src2 = CC_DST - CC_SRC - 1; |
|
86 |
cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1; |
|
87 |
pf = parity_table[(uint8_t)CC_DST]; |
|
88 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
89 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
90 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
91 |
of = lshift((src1 ^ src2 ^ -1) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
92 |
return cf | pf | af | zf | sf | of; |
|
93 |
} |
|
94 |
|
|
95 |
static int glue(compute_c_adc, SUFFIX)(void) |
|
96 |
{ |
|
97 |
int cf; |
|
98 |
target_long src1; |
|
99 |
src1 = CC_SRC; |
|
100 |
cf = (DATA_TYPE)CC_DST <= (DATA_TYPE)src1; |
|
101 |
return cf; |
|
102 |
} |
|
103 |
|
|
104 |
static int glue(compute_all_sub, SUFFIX)(void) |
|
105 |
{ |
|
106 |
int cf, pf, af, zf, sf, of; |
|
107 |
target_long src1, src2; |
|
108 |
src1 = CC_DST + CC_SRC; |
|
109 |
src2 = CC_SRC; |
|
110 |
cf = (DATA_TYPE)src1 < (DATA_TYPE)src2; |
|
111 |
pf = parity_table[(uint8_t)CC_DST]; |
|
112 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
113 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
114 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
115 |
of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
116 |
return cf | pf | af | zf | sf | of; |
|
117 |
} |
|
118 |
|
|
119 |
static int glue(compute_c_sub, SUFFIX)(void) |
|
120 |
{ |
|
121 |
int cf; |
|
122 |
target_long src1, src2; |
|
123 |
src1 = CC_DST + CC_SRC; |
|
124 |
src2 = CC_SRC; |
|
125 |
cf = (DATA_TYPE)src1 < (DATA_TYPE)src2; |
|
126 |
return cf; |
|
127 |
} |
|
128 |
|
|
129 |
static int glue(compute_all_sbb, SUFFIX)(void) |
|
130 |
{ |
|
131 |
int cf, pf, af, zf, sf, of; |
|
132 |
target_long src1, src2; |
|
133 |
src1 = CC_DST + CC_SRC + 1; |
|
134 |
src2 = CC_SRC; |
|
135 |
cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2; |
|
136 |
pf = parity_table[(uint8_t)CC_DST]; |
|
137 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
138 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
139 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
140 |
of = lshift((src1 ^ src2) & (src1 ^ CC_DST), 12 - DATA_BITS) & CC_O; |
|
141 |
return cf | pf | af | zf | sf | of; |
|
142 |
} |
|
143 |
|
|
144 |
static int glue(compute_c_sbb, SUFFIX)(void) |
|
145 |
{ |
|
146 |
int cf; |
|
147 |
target_long src1, src2; |
|
148 |
src1 = CC_DST + CC_SRC + 1; |
|
149 |
src2 = CC_SRC; |
|
150 |
cf = (DATA_TYPE)src1 <= (DATA_TYPE)src2; |
|
151 |
return cf; |
|
152 |
} |
|
153 |
|
|
154 |
static int glue(compute_all_logic, SUFFIX)(void) |
|
155 |
{ |
|
156 |
int cf, pf, af, zf, sf, of; |
|
157 |
cf = 0; |
|
158 |
pf = parity_table[(uint8_t)CC_DST]; |
|
159 |
af = 0; |
|
160 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
161 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
162 |
of = 0; |
|
163 |
return cf | pf | af | zf | sf | of; |
|
164 |
} |
|
165 |
|
|
166 |
static int glue(compute_c_logic, SUFFIX)(void) |
|
167 |
{ |
|
168 |
return 0; |
|
169 |
} |
|
170 |
|
|
171 |
static int glue(compute_all_inc, SUFFIX)(void) |
|
172 |
{ |
|
173 |
int cf, pf, af, zf, sf, of; |
|
174 |
target_long src1, src2; |
|
175 |
src1 = CC_DST - 1; |
|
176 |
src2 = 1; |
|
177 |
cf = CC_SRC; |
|
178 |
pf = parity_table[(uint8_t)CC_DST]; |
|
179 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
180 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
181 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
182 |
of = ((CC_DST & DATA_MASK) == SIGN_MASK) << 11; |
|
183 |
return cf | pf | af | zf | sf | of; |
|
184 |
} |
|
185 |
|
|
186 |
#if DATA_BITS == 32 |
|
187 |
static int glue(compute_c_inc, SUFFIX)(void) |
|
188 |
{ |
|
189 |
return CC_SRC; |
|
190 |
} |
|
191 |
#endif |
|
192 |
|
|
193 |
static int glue(compute_all_dec, SUFFIX)(void) |
|
194 |
{ |
|
195 |
int cf, pf, af, zf, sf, of; |
|
196 |
target_long src1, src2; |
|
197 |
src1 = CC_DST + 1; |
|
198 |
src2 = 1; |
|
199 |
cf = CC_SRC; |
|
200 |
pf = parity_table[(uint8_t)CC_DST]; |
|
201 |
af = (CC_DST ^ src1 ^ src2) & 0x10; |
|
202 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
203 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
204 |
of = ((CC_DST & DATA_MASK) == ((target_ulong)SIGN_MASK - 1)) << 11; |
|
205 |
return cf | pf | af | zf | sf | of; |
|
206 |
} |
|
207 |
|
|
208 |
static int glue(compute_all_shl, SUFFIX)(void) |
|
209 |
{ |
|
210 |
int cf, pf, af, zf, sf, of; |
|
211 |
cf = (CC_SRC >> (DATA_BITS - 1)) & CC_C; |
|
212 |
pf = parity_table[(uint8_t)CC_DST]; |
|
213 |
af = 0; /* undefined */ |
|
214 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
215 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
216 |
/* of is defined if shift count == 1 */ |
|
217 |
of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O; |
|
218 |
return cf | pf | af | zf | sf | of; |
|
219 |
} |
|
220 |
|
|
221 |
static int glue(compute_c_shl, SUFFIX)(void) |
|
222 |
{ |
|
223 |
return (CC_SRC >> (DATA_BITS - 1)) & CC_C; |
|
224 |
} |
|
225 |
|
|
226 |
#if DATA_BITS == 32 |
|
227 |
static int glue(compute_c_sar, SUFFIX)(void) |
|
228 |
{ |
|
229 |
return CC_SRC & 1; |
|
230 |
} |
|
231 |
#endif |
|
232 |
|
|
233 |
static int glue(compute_all_sar, SUFFIX)(void) |
|
234 |
{ |
|
235 |
int cf, pf, af, zf, sf, of; |
|
236 |
cf = CC_SRC & 1; |
|
237 |
pf = parity_table[(uint8_t)CC_DST]; |
|
238 |
af = 0; /* undefined */ |
|
239 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
240 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
241 |
/* of is defined if shift count == 1 */ |
|
242 |
of = lshift(CC_SRC ^ CC_DST, 12 - DATA_BITS) & CC_O; |
|
243 |
return cf | pf | af | zf | sf | of; |
|
244 |
} |
|
245 |
|
|
246 |
#if DATA_BITS == 32 |
|
247 |
static int glue(compute_c_mul, SUFFIX)(void) |
|
248 |
{ |
|
249 |
int cf; |
|
250 |
cf = (CC_SRC != 0); |
|
251 |
return cf; |
|
252 |
} |
|
253 |
#endif |
|
254 |
|
|
255 |
/* NOTE: we compute the flags like the P4. On olders CPUs, only OF and |
|
256 |
CF are modified and it is slower to do that. */ |
|
257 |
static int glue(compute_all_mul, SUFFIX)(void) |
|
258 |
{ |
|
259 |
int cf, pf, af, zf, sf, of; |
|
260 |
cf = (CC_SRC != 0); |
|
261 |
pf = parity_table[(uint8_t)CC_DST]; |
|
262 |
af = 0; /* undefined */ |
|
263 |
zf = ((DATA_TYPE)CC_DST == 0) << 6; |
|
264 |
sf = lshift(CC_DST, 8 - DATA_BITS) & 0x80; |
|
265 |
of = cf << 11; |
|
266 |
return cf | pf | af | zf | sf | of; |
|
267 |
} |
|
268 |
|
|
269 | 54 |
/* various optimized jumps cases */ |
270 | 55 |
|
271 | 56 |
void OPPROTO glue(op_jb_sub, SUFFIX)(void) |
Also available in: Unified diff