vfpsingle.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. /*
  2. * linux/arch/arm/vfp/vfpsingle.c
  3. *
  4. * This code is derived in part from John R. Housers softfloat library, which
  5. * carries the following notice:
  6. *
  7. * ===========================================================================
  8. * This C source file is part of the SoftFloat IEC/IEEE Floating-point
  9. * Arithmetic Package, Release 2.
  10. *
  11. * Written by John R. Hauser. This work was made possible in part by the
  12. * International Computer Science Institute, located at Suite 600, 1947 Center
  13. * Street, Berkeley, California 94704. Funding was partially provided by the
  14. * National Science Foundation under grant MIP-9311980. The original version
  15. * of this code was written as part of a project to build a fixed-point vector
  16. * processor in collaboration with the University of California at Berkeley,
  17. * overseen by Profs. Nelson Morgan and John Wawrzynek. More information
  18. * is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
  19. * arithmetic/softfloat.html'.
  20. *
  21. * THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
  22. * has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
  23. * TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
  24. * PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
  25. * AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
  26. *
  27. * Derivative works are acceptable, even for commercial purposes, so long as
  28. * (1) they include prominent notice that the work is derivative, and (2) they
  29. * include prominent notice akin to these three paragraphs for those parts of
  30. * this code that are retained.
  31. * ===========================================================================
  32. */
  33. #include <linux/kernel.h>
  34. #include <linux/bitops.h>
  35. #include <asm/div64.h>
  36. #include <asm/vfp.h>
  37. #include "vfpinstr.h"
  38. #include "vfp.h"
  39. static struct vfp_single vfp_single_default_qnan = {
  40. .exponent = 255,
  41. .sign = 0,
  42. .significand = VFP_SINGLE_SIGNIFICAND_QNAN,
  43. };
  44. static void vfp_single_dump(const char *str, struct vfp_single *s)
  45. {
  46. pr_debug("VFP: %s: sign=%d exponent=%d significand=%08x\n",
  47. str, s->sign != 0, s->exponent, s->significand);
  48. }
  49. static void vfp_single_normalise_denormal(struct vfp_single *vs)
  50. {
  51. int bits = 31 - fls(vs->significand);
  52. vfp_single_dump("normalise_denormal: in", vs);
  53. if (bits) {
  54. vs->exponent -= bits - 1;
  55. vs->significand <<= bits;
  56. }
  57. vfp_single_dump("normalise_denormal: out", vs);
  58. }
  59. #ifndef DEBUG
  60. #define vfp_single_normaliseround(sd,vsd,fpscr,except,func) __vfp_single_normaliseround(sd,vsd,fpscr,except)
  61. u32 __vfp_single_normaliseround(int sd, struct vfp_single *vs, u32 fpscr, u32 exceptions)
  62. #else
  63. u32 vfp_single_normaliseround(int sd, struct vfp_single *vs, u32 fpscr, u32 exceptions, const char *func)
  64. #endif
  65. {
  66. u32 significand, incr, rmode;
  67. int exponent, shift, underflow;
  68. vfp_single_dump("pack: in", vs);
  69. /*
  70. * Infinities and NaNs are a special case.
  71. */
  72. if (vs->exponent == 255 && (vs->significand == 0 || exceptions))
  73. goto pack;
  74. /*
  75. * Special-case zero.
  76. */
  77. if (vs->significand == 0) {
  78. vs->exponent = 0;
  79. goto pack;
  80. }
  81. exponent = vs->exponent;
  82. significand = vs->significand;
  83. /*
  84. * Normalise first. Note that we shift the significand up to
  85. * bit 31, so we have VFP_SINGLE_LOW_BITS + 1 below the least
  86. * significant bit.
  87. */
  88. shift = 32 - fls(significand);
  89. if (shift < 32 && shift) {
  90. exponent -= shift;
  91. significand <<= shift;
  92. }
  93. #ifdef DEBUG
  94. vs->exponent = exponent;
  95. vs->significand = significand;
  96. vfp_single_dump("pack: normalised", vs);
  97. #endif
  98. /*
  99. * Tiny number?
  100. */
  101. underflow = exponent < 0;
  102. if (underflow) {
  103. significand = vfp_shiftright32jamming(significand, -exponent);
  104. exponent = 0;
  105. #ifdef DEBUG
  106. vs->exponent = exponent;
  107. vs->significand = significand;
  108. vfp_single_dump("pack: tiny number", vs);
  109. #endif
  110. if (!(significand & ((1 << (VFP_SINGLE_LOW_BITS + 1)) - 1)))
  111. underflow = 0;
  112. }
  113. /*
  114. * Select rounding increment.
  115. */
  116. incr = 0;
  117. rmode = fpscr & FPSCR_RMODE_MASK;
  118. if (rmode == FPSCR_ROUND_NEAREST) {
  119. incr = 1 << VFP_SINGLE_LOW_BITS;
  120. if ((significand & (1 << (VFP_SINGLE_LOW_BITS + 1))) == 0)
  121. incr -= 1;
  122. } else if (rmode == FPSCR_ROUND_TOZERO) {
  123. incr = 0;
  124. } else if ((rmode == FPSCR_ROUND_PLUSINF) ^ (vs->sign != 0))
  125. incr = (1 << (VFP_SINGLE_LOW_BITS + 1)) - 1;
  126. pr_debug("VFP: rounding increment = 0x%08x\n", incr);
  127. /*
  128. * Is our rounding going to overflow?
  129. */
  130. if ((significand + incr) < significand) {
  131. exponent += 1;
  132. significand = (significand >> 1) | (significand & 1);
  133. incr >>= 1;
  134. #ifdef DEBUG
  135. vs->exponent = exponent;
  136. vs->significand = significand;
  137. vfp_single_dump("pack: overflow", vs);
  138. #endif
  139. }
  140. /*
  141. * If any of the low bits (which will be shifted out of the
  142. * number) are non-zero, the result is inexact.
  143. */
  144. if (significand & ((1 << (VFP_SINGLE_LOW_BITS + 1)) - 1))
  145. exceptions |= FPSCR_IXC;
  146. /*
  147. * Do our rounding.
  148. */
  149. significand += incr;
  150. /*
  151. * Infinity?
  152. */
  153. if (exponent >= 254) {
  154. exceptions |= FPSCR_OFC | FPSCR_IXC;
  155. if (incr == 0) {
  156. vs->exponent = 253;
  157. vs->significand = 0x7fffffff;
  158. } else {
  159. vs->exponent = 255; /* infinity */
  160. vs->significand = 0;
  161. }
  162. } else {
  163. if (significand >> (VFP_SINGLE_LOW_BITS + 1) == 0)
  164. exponent = 0;
  165. if (exponent || significand > 0x80000000)
  166. underflow = 0;
  167. if (underflow)
  168. exceptions |= FPSCR_UFC;
  169. vs->exponent = exponent;
  170. vs->significand = significand >> 1;
  171. }
  172. pack:
  173. vfp_single_dump("pack: final", vs);
  174. {
  175. s32 d = vfp_single_pack(vs);
  176. #ifdef DEBUG
  177. pr_debug("VFP: %s: d(s%d)=%08x exceptions=%08x\n", func,
  178. sd, d, exceptions);
  179. #endif
  180. vfp_put_float(d, sd);
  181. }
  182. return exceptions;
  183. }
  184. /*
  185. * Propagate the NaN, setting exceptions if it is signalling.
  186. * 'n' is always a NaN. 'm' may be a number, NaN or infinity.
  187. */
  188. static u32
  189. vfp_propagate_nan(struct vfp_single *vsd, struct vfp_single *vsn,
  190. struct vfp_single *vsm, u32 fpscr)
  191. {
  192. struct vfp_single *nan;
  193. int tn, tm = 0;
  194. tn = vfp_single_type(vsn);
  195. if (vsm)
  196. tm = vfp_single_type(vsm);
  197. if (fpscr & FPSCR_DEFAULT_NAN)
  198. /*
  199. * Default NaN mode - always returns a quiet NaN
  200. */
  201. nan = &vfp_single_default_qnan;
  202. else {
  203. /*
  204. * Contemporary mode - select the first signalling
  205. * NAN, or if neither are signalling, the first
  206. * quiet NAN.
  207. */
  208. if (tn == VFP_SNAN || (tm != VFP_SNAN && tn == VFP_QNAN))
  209. nan = vsn;
  210. else
  211. nan = vsm;
  212. /*
  213. * Make the NaN quiet.
  214. */
  215. nan->significand |= VFP_SINGLE_SIGNIFICAND_QNAN;
  216. }
  217. *vsd = *nan;
  218. /*
  219. * If one was a signalling NAN, raise invalid operation.
  220. */
  221. return tn == VFP_SNAN || tm == VFP_SNAN ? FPSCR_IOC : VFP_NAN_FLAG;
  222. }
  223. /*
  224. * Extended operations
  225. */
  226. static u32 vfp_single_fabs(int sd, int unused, s32 m, u32 fpscr)
  227. {
  228. vfp_put_float(vfp_single_packed_abs(m), sd);
  229. return 0;
  230. }
  231. static u32 vfp_single_fcpy(int sd, int unused, s32 m, u32 fpscr)
  232. {
  233. vfp_put_float(m, sd);
  234. return 0;
  235. }
  236. static u32 vfp_single_fneg(int sd, int unused, s32 m, u32 fpscr)
  237. {
  238. vfp_put_float(vfp_single_packed_negate(m), sd);
  239. return 0;
  240. }
  241. static const u16 sqrt_oddadjust[] = {
  242. 0x0004, 0x0022, 0x005d, 0x00b1, 0x011d, 0x019f, 0x0236, 0x02e0,
  243. 0x039c, 0x0468, 0x0545, 0x0631, 0x072b, 0x0832, 0x0946, 0x0a67
  244. };
  245. static const u16 sqrt_evenadjust[] = {
  246. 0x0a2d, 0x08af, 0x075a, 0x0629, 0x051a, 0x0429, 0x0356, 0x029e,
  247. 0x0200, 0x0179, 0x0109, 0x00af, 0x0068, 0x0034, 0x0012, 0x0002
  248. };
  249. u32 vfp_estimate_sqrt_significand(u32 exponent, u32 significand)
  250. {
  251. int index;
  252. u32 z, a;
  253. if ((significand & 0xc0000000) != 0x40000000) {
  254. pr_warn("VFP: estimate_sqrt: invalid significand\n");
  255. }
  256. a = significand << 1;
  257. index = (a >> 27) & 15;
  258. if (exponent & 1) {
  259. z = 0x4000 + (a >> 17) - sqrt_oddadjust[index];
  260. z = ((a / z) << 14) + (z << 15);
  261. a >>= 1;
  262. } else {
  263. z = 0x8000 + (a >> 17) - sqrt_evenadjust[index];
  264. z = a / z + z;
  265. z = (z >= 0x20000) ? 0xffff8000 : (z << 15);
  266. if (z <= a)
  267. return (s32)a >> 1;
  268. }
  269. {
  270. u64 v = (u64)a << 31;
  271. do_div(v, z);
  272. return v + (z >> 1);
  273. }
  274. }
  275. static u32 vfp_single_fsqrt(int sd, int unused, s32 m, u32 fpscr)
  276. {
  277. struct vfp_single vsm, vsd;
  278. int ret, tm;
  279. vfp_single_unpack(&vsm, m);
  280. tm = vfp_single_type(&vsm);
  281. if (tm & (VFP_NAN|VFP_INFINITY)) {
  282. struct vfp_single *vsp = &vsd;
  283. if (tm & VFP_NAN)
  284. ret = vfp_propagate_nan(vsp, &vsm, NULL, fpscr);
  285. else if (vsm.sign == 0) {
  286. sqrt_copy:
  287. vsp = &vsm;
  288. ret = 0;
  289. } else {
  290. sqrt_invalid:
  291. vsp = &vfp_single_default_qnan;
  292. ret = FPSCR_IOC;
  293. }
  294. vfp_put_float(vfp_single_pack(vsp), sd);
  295. return ret;
  296. }
  297. /*
  298. * sqrt(+/- 0) == +/- 0
  299. */
  300. if (tm & VFP_ZERO)
  301. goto sqrt_copy;
  302. /*
  303. * Normalise a denormalised number
  304. */
  305. if (tm & VFP_DENORMAL)
  306. vfp_single_normalise_denormal(&vsm);
  307. /*
  308. * sqrt(<0) = invalid
  309. */
  310. if (vsm.sign)
  311. goto sqrt_invalid;
  312. vfp_single_dump("sqrt", &vsm);
  313. /*
  314. * Estimate the square root.
  315. */
  316. vsd.sign = 0;
  317. vsd.exponent = ((vsm.exponent - 127) >> 1) + 127;
  318. vsd.significand = vfp_estimate_sqrt_significand(vsm.exponent, vsm.significand) + 2;
  319. vfp_single_dump("sqrt estimate", &vsd);
  320. /*
  321. * And now adjust.
  322. */
  323. if ((vsd.significand & VFP_SINGLE_LOW_BITS_MASK) <= 5) {
  324. if (vsd.significand < 2) {
  325. vsd.significand = 0xffffffff;
  326. } else {
  327. u64 term;
  328. s64 rem;
  329. vsm.significand <<= !(vsm.exponent & 1);
  330. term = (u64)vsd.significand * vsd.significand;
  331. rem = ((u64)vsm.significand << 32) - term;
  332. pr_debug("VFP: term=%016llx rem=%016llx\n", term, rem);
  333. while (rem < 0) {
  334. vsd.significand -= 1;
  335. rem += ((u64)vsd.significand << 1) | 1;
  336. }
  337. vsd.significand |= rem != 0;
  338. }
  339. }
  340. vsd.significand = vfp_shiftright32jamming(vsd.significand, 1);
  341. return vfp_single_normaliseround(sd, &vsd, fpscr, 0, "fsqrt");
  342. }
  343. /*
  344. * Equal := ZC
  345. * Less than := N
  346. * Greater than := C
  347. * Unordered := CV
  348. */
  349. static u32 vfp_compare(int sd, int signal_on_qnan, s32 m, u32 fpscr)
  350. {
  351. s32 d;
  352. u32 ret = 0;
  353. d = vfp_get_float(sd);
  354. if (vfp_single_packed_exponent(m) == 255 && vfp_single_packed_mantissa(m)) {
  355. ret |= FPSCR_C | FPSCR_V;
  356. if (signal_on_qnan || !(vfp_single_packed_mantissa(m) & (1 << (VFP_SINGLE_MANTISSA_BITS - 1))))
  357. /*
  358. * Signalling NaN, or signalling on quiet NaN
  359. */
  360. ret |= FPSCR_IOC;
  361. }
  362. if (vfp_single_packed_exponent(d) == 255 && vfp_single_packed_mantissa(d)) {
  363. ret |= FPSCR_C | FPSCR_V;
  364. if (signal_on_qnan || !(vfp_single_packed_mantissa(d) & (1 << (VFP_SINGLE_MANTISSA_BITS - 1))))
  365. /*
  366. * Signalling NaN, or signalling on quiet NaN
  367. */
  368. ret |= FPSCR_IOC;
  369. }
  370. if (ret == 0) {
  371. if (d == m || vfp_single_packed_abs(d | m) == 0) {
  372. /*
  373. * equal
  374. */
  375. ret |= FPSCR_Z | FPSCR_C;
  376. } else if (vfp_single_packed_sign(d ^ m)) {
  377. /*
  378. * different signs
  379. */
  380. if (vfp_single_packed_sign(d))
  381. /*
  382. * d is negative, so d < m
  383. */
  384. ret |= FPSCR_N;
  385. else
  386. /*
  387. * d is positive, so d > m
  388. */
  389. ret |= FPSCR_C;
  390. } else if ((vfp_single_packed_sign(d) != 0) ^ (d < m)) {
  391. /*
  392. * d < m
  393. */
  394. ret |= FPSCR_N;
  395. } else if ((vfp_single_packed_sign(d) != 0) ^ (d > m)) {
  396. /*
  397. * d > m
  398. */
  399. ret |= FPSCR_C;
  400. }
  401. }
  402. return ret;
  403. }
  404. static u32 vfp_single_fcmp(int sd, int unused, s32 m, u32 fpscr)
  405. {
  406. return vfp_compare(sd, 0, m, fpscr);
  407. }
  408. static u32 vfp_single_fcmpe(int sd, int unused, s32 m, u32 fpscr)
  409. {
  410. return vfp_compare(sd, 1, m, fpscr);
  411. }
  412. static u32 vfp_single_fcmpz(int sd, int unused, s32 m, u32 fpscr)
  413. {
  414. return vfp_compare(sd, 0, 0, fpscr);
  415. }
  416. static u32 vfp_single_fcmpez(int sd, int unused, s32 m, u32 fpscr)
  417. {
  418. return vfp_compare(sd, 1, 0, fpscr);
  419. }
  420. static u32 vfp_single_fcvtd(int dd, int unused, s32 m, u32 fpscr)
  421. {
  422. struct vfp_single vsm;
  423. struct vfp_double vdd;
  424. int tm;
  425. u32 exceptions = 0;
  426. vfp_single_unpack(&vsm, m);
  427. tm = vfp_single_type(&vsm);
  428. /*
  429. * If we have a signalling NaN, signal invalid operation.
  430. */
  431. if (tm == VFP_SNAN)
  432. exceptions = FPSCR_IOC;
  433. if (tm & VFP_DENORMAL)
  434. vfp_single_normalise_denormal(&vsm);
  435. vdd.sign = vsm.sign;
  436. vdd.significand = (u64)vsm.significand << 32;
  437. /*
  438. * If we have an infinity or NaN, the exponent must be 2047.
  439. */
  440. if (tm & (VFP_INFINITY|VFP_NAN)) {
  441. vdd.exponent = 2047;
  442. if (tm == VFP_QNAN)
  443. vdd.significand |= VFP_DOUBLE_SIGNIFICAND_QNAN;
  444. goto pack_nan;
  445. } else if (tm & VFP_ZERO)
  446. vdd.exponent = 0;
  447. else
  448. vdd.exponent = vsm.exponent + (1023 - 127);
  449. return vfp_double_normaliseround(dd, &vdd, fpscr, exceptions, "fcvtd");
  450. pack_nan:
  451. vfp_put_double(vfp_double_pack(&vdd), dd);
  452. return exceptions;
  453. }
  454. static u32 vfp_single_fuito(int sd, int unused, s32 m, u32 fpscr)
  455. {
  456. struct vfp_single vs;
  457. vs.sign = 0;
  458. vs.exponent = 127 + 31 - 1;
  459. vs.significand = (u32)m;
  460. return vfp_single_normaliseround(sd, &vs, fpscr, 0, "fuito");
  461. }
  462. static u32 vfp_single_fsito(int sd, int unused, s32 m, u32 fpscr)
  463. {
  464. struct vfp_single vs;
  465. vs.sign = (m & 0x80000000) >> 16;
  466. vs.exponent = 127 + 31 - 1;
  467. vs.significand = vs.sign ? -m : m;
  468. return vfp_single_normaliseround(sd, &vs, fpscr, 0, "fsito");
  469. }
  470. static u32 vfp_single_ftoui(int sd, int unused, s32 m, u32 fpscr)
  471. {
  472. struct vfp_single vsm;
  473. u32 d, exceptions = 0;
  474. int rmode = fpscr & FPSCR_RMODE_MASK;
  475. int tm;
  476. vfp_single_unpack(&vsm, m);
  477. vfp_single_dump("VSM", &vsm);
  478. /*
  479. * Do we have a denormalised number?
  480. */
  481. tm = vfp_single_type(&vsm);
  482. if (tm & VFP_DENORMAL)
  483. exceptions |= FPSCR_IDC;
  484. if (tm & VFP_NAN)
  485. vsm.sign = 0;
  486. if (vsm.exponent >= 127 + 32) {
  487. d = vsm.sign ? 0 : 0xffffffff;
  488. exceptions = FPSCR_IOC;
  489. } else if (vsm.exponent >= 127 - 1) {
  490. int shift = 127 + 31 - vsm.exponent;
  491. u32 rem, incr = 0;
  492. /*
  493. * 2^0 <= m < 2^32-2^8
  494. */
  495. d = (vsm.significand << 1) >> shift;
  496. rem = vsm.significand << (33 - shift);
  497. if (rmode == FPSCR_ROUND_NEAREST) {
  498. incr = 0x80000000;
  499. if ((d & 1) == 0)
  500. incr -= 1;
  501. } else if (rmode == FPSCR_ROUND_TOZERO) {
  502. incr = 0;
  503. } else if ((rmode == FPSCR_ROUND_PLUSINF) ^ (vsm.sign != 0)) {
  504. incr = ~0;
  505. }
  506. if ((rem + incr) < rem) {
  507. if (d < 0xffffffff)
  508. d += 1;
  509. else
  510. exceptions |= FPSCR_IOC;
  511. }
  512. if (d && vsm.sign) {
  513. d = 0;
  514. exceptions |= FPSCR_IOC;
  515. } else if (rem)
  516. exceptions |= FPSCR_IXC;
  517. } else {
  518. d = 0;
  519. if (vsm.exponent | vsm.significand) {
  520. exceptions |= FPSCR_IXC;
  521. if (rmode == FPSCR_ROUND_PLUSINF && vsm.sign == 0)
  522. d = 1;
  523. else if (rmode == FPSCR_ROUND_MINUSINF && vsm.sign) {
  524. d = 0;
  525. exceptions |= FPSCR_IOC;
  526. }
  527. }
  528. }
  529. pr_debug("VFP: ftoui: d(s%d)=%08x exceptions=%08x\n", sd, d, exceptions);
  530. vfp_put_float(d, sd);
  531. return exceptions;
  532. }
  533. static u32 vfp_single_ftouiz(int sd, int unused, s32 m, u32 fpscr)
  534. {
  535. return vfp_single_ftoui(sd, unused, m, FPSCR_ROUND_TOZERO);
  536. }
  537. static u32 vfp_single_ftosi(int sd, int unused, s32 m, u32 fpscr)
  538. {
  539. struct vfp_single vsm;
  540. u32 d, exceptions = 0;
  541. int rmode = fpscr & FPSCR_RMODE_MASK;
  542. int tm;
  543. vfp_single_unpack(&vsm, m);
  544. vfp_single_dump("VSM", &vsm);
  545. /*
  546. * Do we have a denormalised number?
  547. */
  548. tm = vfp_single_type(&vsm);
  549. if (vfp_single_type(&vsm) & VFP_DENORMAL)
  550. exceptions |= FPSCR_IDC;
  551. if (tm & VFP_NAN) {
  552. d = 0;
  553. exceptions |= FPSCR_IOC;
  554. } else if (vsm.exponent >= 127 + 32) {
  555. /*
  556. * m >= 2^31-2^7: invalid
  557. */
  558. d = 0x7fffffff;
  559. if (vsm.sign)
  560. d = ~d;
  561. exceptions |= FPSCR_IOC;
  562. } else if (vsm.exponent >= 127 - 1) {
  563. int shift = 127 + 31 - vsm.exponent;
  564. u32 rem, incr = 0;
  565. /* 2^0 <= m <= 2^31-2^7 */
  566. d = (vsm.significand << 1) >> shift;
  567. rem = vsm.significand << (33 - shift);
  568. if (rmode == FPSCR_ROUND_NEAREST) {
  569. incr = 0x80000000;
  570. if ((d & 1) == 0)
  571. incr -= 1;
  572. } else if (rmode == FPSCR_ROUND_TOZERO) {
  573. incr = 0;
  574. } else if ((rmode == FPSCR_ROUND_PLUSINF) ^ (vsm.sign != 0)) {
  575. incr = ~0;
  576. }
  577. if ((rem + incr) < rem && d < 0xffffffff)
  578. d += 1;
  579. if (d > 0x7fffffff + (vsm.sign != 0)) {
  580. d = 0x7fffffff + (vsm.sign != 0);
  581. exceptions |= FPSCR_IOC;
  582. } else if (rem)
  583. exceptions |= FPSCR_IXC;
  584. if (vsm.sign)
  585. d = -d;
  586. } else {
  587. d = 0;
  588. if (vsm.exponent | vsm.significand) {
  589. exceptions |= FPSCR_IXC;
  590. if (rmode == FPSCR_ROUND_PLUSINF && vsm.sign == 0)
  591. d = 1;
  592. else if (rmode == FPSCR_ROUND_MINUSINF && vsm.sign)
  593. d = -1;
  594. }
  595. }
  596. pr_debug("VFP: ftosi: d(s%d)=%08x exceptions=%08x\n", sd, d, exceptions);
  597. vfp_put_float((s32)d, sd);
  598. return exceptions;
  599. }
  600. static u32 vfp_single_ftosiz(int sd, int unused, s32 m, u32 fpscr)
  601. {
  602. return vfp_single_ftosi(sd, unused, m, FPSCR_ROUND_TOZERO);
  603. }
  604. static struct op fops_ext[32] = {
  605. [FEXT_TO_IDX(FEXT_FCPY)] = { vfp_single_fcpy, 0 },
  606. [FEXT_TO_IDX(FEXT_FABS)] = { vfp_single_fabs, 0 },
  607. [FEXT_TO_IDX(FEXT_FNEG)] = { vfp_single_fneg, 0 },
  608. [FEXT_TO_IDX(FEXT_FSQRT)] = { vfp_single_fsqrt, 0 },
  609. [FEXT_TO_IDX(FEXT_FCMP)] = { vfp_single_fcmp, OP_SCALAR },
  610. [FEXT_TO_IDX(FEXT_FCMPE)] = { vfp_single_fcmpe, OP_SCALAR },
  611. [FEXT_TO_IDX(FEXT_FCMPZ)] = { vfp_single_fcmpz, OP_SCALAR },
  612. [FEXT_TO_IDX(FEXT_FCMPEZ)] = { vfp_single_fcmpez, OP_SCALAR },
  613. [FEXT_TO_IDX(FEXT_FCVT)] = { vfp_single_fcvtd, OP_SCALAR|OP_DD },
  614. [FEXT_TO_IDX(FEXT_FUITO)] = { vfp_single_fuito, OP_SCALAR },
  615. [FEXT_TO_IDX(FEXT_FSITO)] = { vfp_single_fsito, OP_SCALAR },
  616. [FEXT_TO_IDX(FEXT_FTOUI)] = { vfp_single_ftoui, OP_SCALAR },
  617. [FEXT_TO_IDX(FEXT_FTOUIZ)] = { vfp_single_ftouiz, OP_SCALAR },
  618. [FEXT_TO_IDX(FEXT_FTOSI)] = { vfp_single_ftosi, OP_SCALAR },
  619. [FEXT_TO_IDX(FEXT_FTOSIZ)] = { vfp_single_ftosiz, OP_SCALAR },
  620. };
  621. static u32
  622. vfp_single_fadd_nonnumber(struct vfp_single *vsd, struct vfp_single *vsn,
  623. struct vfp_single *vsm, u32 fpscr)
  624. {
  625. struct vfp_single *vsp;
  626. u32 exceptions = 0;
  627. int tn, tm;
  628. tn = vfp_single_type(vsn);
  629. tm = vfp_single_type(vsm);
  630. if (tn & tm & VFP_INFINITY) {
  631. /*
  632. * Two infinities. Are they different signs?
  633. */
  634. if (vsn->sign ^ vsm->sign) {
  635. /*
  636. * different signs -> invalid
  637. */
  638. exceptions = FPSCR_IOC;
  639. vsp = &vfp_single_default_qnan;
  640. } else {
  641. /*
  642. * same signs -> valid
  643. */
  644. vsp = vsn;
  645. }
  646. } else if (tn & VFP_INFINITY && tm & VFP_NUMBER) {
  647. /*
  648. * One infinity and one number -> infinity
  649. */
  650. vsp = vsn;
  651. } else {
  652. /*
  653. * 'n' is a NaN of some type
  654. */
  655. return vfp_propagate_nan(vsd, vsn, vsm, fpscr);
  656. }
  657. *vsd = *vsp;
  658. return exceptions;
  659. }
  660. static u32
  661. vfp_single_add(struct vfp_single *vsd, struct vfp_single *vsn,
  662. struct vfp_single *vsm, u32 fpscr)
  663. {
  664. u32 exp_diff, m_sig;
  665. if (vsn->significand & 0x80000000 ||
  666. vsm->significand & 0x80000000) {
  667. pr_info("VFP: bad FP values in %s\n", __func__);
  668. vfp_single_dump("VSN", vsn);
  669. vfp_single_dump("VSM", vsm);
  670. }
  671. /*
  672. * Ensure that 'n' is the largest magnitude number. Note that
  673. * if 'n' and 'm' have equal exponents, we do not swap them.
  674. * This ensures that NaN propagation works correctly.
  675. */
  676. if (vsn->exponent < vsm->exponent) {
  677. struct vfp_single *t = vsn;
  678. vsn = vsm;
  679. vsm = t;
  680. }
  681. /*
  682. * Is 'n' an infinity or a NaN? Note that 'm' may be a number,
  683. * infinity or a NaN here.
  684. */
  685. if (vsn->exponent == 255)
  686. return vfp_single_fadd_nonnumber(vsd, vsn, vsm, fpscr);
  687. /*
  688. * We have two proper numbers, where 'vsn' is the larger magnitude.
  689. *
  690. * Copy 'n' to 'd' before doing the arithmetic.
  691. */
  692. *vsd = *vsn;
  693. /*
  694. * Align both numbers.
  695. */
  696. exp_diff = vsn->exponent - vsm->exponent;
  697. m_sig = vfp_shiftright32jamming(vsm->significand, exp_diff);
  698. /*
  699. * If the signs are different, we are really subtracting.
  700. */
  701. if (vsn->sign ^ vsm->sign) {
  702. m_sig = vsn->significand - m_sig;
  703. if ((s32)m_sig < 0) {
  704. vsd->sign = vfp_sign_negate(vsd->sign);
  705. m_sig = -m_sig;
  706. } else if (m_sig == 0) {
  707. vsd->sign = (fpscr & FPSCR_RMODE_MASK) ==
  708. FPSCR_ROUND_MINUSINF ? 0x8000 : 0;
  709. }
  710. } else {
  711. m_sig = vsn->significand + m_sig;
  712. }
  713. vsd->significand = m_sig;
  714. return 0;
  715. }
  716. static u32
  717. vfp_single_multiply(struct vfp_single *vsd, struct vfp_single *vsn, struct vfp_single *vsm, u32 fpscr)
  718. {
  719. vfp_single_dump("VSN", vsn);
  720. vfp_single_dump("VSM", vsm);
  721. /*
  722. * Ensure that 'n' is the largest magnitude number. Note that
  723. * if 'n' and 'm' have equal exponents, we do not swap them.
  724. * This ensures that NaN propagation works correctly.
  725. */
  726. if (vsn->exponent < vsm->exponent) {
  727. struct vfp_single *t = vsn;
  728. vsn = vsm;
  729. vsm = t;
  730. pr_debug("VFP: swapping M <-> N\n");
  731. }
  732. vsd->sign = vsn->sign ^ vsm->sign;
  733. /*
  734. * If 'n' is an infinity or NaN, handle it. 'm' may be anything.
  735. */
  736. if (vsn->exponent == 255) {
  737. if (vsn->significand || (vsm->exponent == 255 && vsm->significand))
  738. return vfp_propagate_nan(vsd, vsn, vsm, fpscr);
  739. if ((vsm->exponent | vsm->significand) == 0) {
  740. *vsd = vfp_single_default_qnan;
  741. return FPSCR_IOC;
  742. }
  743. vsd->exponent = vsn->exponent;
  744. vsd->significand = 0;
  745. return 0;
  746. }
  747. /*
  748. * If 'm' is zero, the result is always zero. In this case,
  749. * 'n' may be zero or a number, but it doesn't matter which.
  750. */
  751. if ((vsm->exponent | vsm->significand) == 0) {
  752. vsd->exponent = 0;
  753. vsd->significand = 0;
  754. return 0;
  755. }
  756. /*
  757. * We add 2 to the destination exponent for the same reason as
  758. * the addition case - though this time we have +1 from each
  759. * input operand.
  760. */
  761. vsd->exponent = vsn->exponent + vsm->exponent - 127 + 2;
  762. vsd->significand = vfp_hi64to32jamming((u64)vsn->significand * vsm->significand);
  763. vfp_single_dump("VSD", vsd);
  764. return 0;
  765. }
  766. #define NEG_MULTIPLY (1 << 0)
  767. #define NEG_SUBTRACT (1 << 1)
  768. static u32
  769. vfp_single_multiply_accumulate(int sd, int sn, s32 m, u32 fpscr, u32 negate, char *func)
  770. {
  771. struct vfp_single vsd, vsp, vsn, vsm;
  772. u32 exceptions;
  773. s32 v;
  774. v = vfp_get_float(sn);
  775. pr_debug("VFP: s%u = %08x\n", sn, v);
  776. vfp_single_unpack(&vsn, v);
  777. if (vsn.exponent == 0 && vsn.significand)
  778. vfp_single_normalise_denormal(&vsn);
  779. vfp_single_unpack(&vsm, m);
  780. if (vsm.exponent == 0 && vsm.significand)
  781. vfp_single_normalise_denormal(&vsm);
  782. exceptions = vfp_single_multiply(&vsp, &vsn, &vsm, fpscr);
  783. if (negate & NEG_MULTIPLY)
  784. vsp.sign = vfp_sign_negate(vsp.sign);
  785. v = vfp_get_float(sd);
  786. pr_debug("VFP: s%u = %08x\n", sd, v);
  787. vfp_single_unpack(&vsn, v);
  788. if (vsn.exponent == 0 && vsn.significand)
  789. vfp_single_normalise_denormal(&vsn);
  790. if (negate & NEG_SUBTRACT)
  791. vsn.sign = vfp_sign_negate(vsn.sign);
  792. exceptions |= vfp_single_add(&vsd, &vsn, &vsp, fpscr);
  793. return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, func);
  794. }
  795. /*
  796. * Standard operations
  797. */
  798. /*
  799. * sd = sd + (sn * sm)
  800. */
  801. static u32 vfp_single_fmac(int sd, int sn, s32 m, u32 fpscr)
  802. {
  803. return vfp_single_multiply_accumulate(sd, sn, m, fpscr, 0, "fmac");
  804. }
  805. /*
  806. * sd = sd - (sn * sm)
  807. */
  808. static u32 vfp_single_fnmac(int sd, int sn, s32 m, u32 fpscr)
  809. {
  810. return vfp_single_multiply_accumulate(sd, sn, m, fpscr, NEG_MULTIPLY, "fnmac");
  811. }
  812. /*
  813. * sd = -sd + (sn * sm)
  814. */
  815. static u32 vfp_single_fmsc(int sd, int sn, s32 m, u32 fpscr)
  816. {
  817. return vfp_single_multiply_accumulate(sd, sn, m, fpscr, NEG_SUBTRACT, "fmsc");
  818. }
  819. /*
  820. * sd = -sd - (sn * sm)
  821. */
  822. static u32 vfp_single_fnmsc(int sd, int sn, s32 m, u32 fpscr)
  823. {
  824. return vfp_single_multiply_accumulate(sd, sn, m, fpscr, NEG_SUBTRACT | NEG_MULTIPLY, "fnmsc");
  825. }
  826. /*
  827. * sd = sn * sm
  828. */
  829. static u32 vfp_single_fmul(int sd, int sn, s32 m, u32 fpscr)
  830. {
  831. struct vfp_single vsd, vsn, vsm;
  832. u32 exceptions;
  833. s32 n = vfp_get_float(sn);
  834. pr_debug("VFP: s%u = %08x\n", sn, n);
  835. vfp_single_unpack(&vsn, n);
  836. if (vsn.exponent == 0 && vsn.significand)
  837. vfp_single_normalise_denormal(&vsn);
  838. vfp_single_unpack(&vsm, m);
  839. if (vsm.exponent == 0 && vsm.significand)
  840. vfp_single_normalise_denormal(&vsm);
  841. exceptions = vfp_single_multiply(&vsd, &vsn, &vsm, fpscr);
  842. return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, "fmul");
  843. }
  844. /*
  845. * sd = -(sn * sm)
  846. */
  847. static u32 vfp_single_fnmul(int sd, int sn, s32 m, u32 fpscr)
  848. {
  849. struct vfp_single vsd, vsn, vsm;
  850. u32 exceptions;
  851. s32 n = vfp_get_float(sn);
  852. pr_debug("VFP: s%u = %08x\n", sn, n);
  853. vfp_single_unpack(&vsn, n);
  854. if (vsn.exponent == 0 && vsn.significand)
  855. vfp_single_normalise_denormal(&vsn);
  856. vfp_single_unpack(&vsm, m);
  857. if (vsm.exponent == 0 && vsm.significand)
  858. vfp_single_normalise_denormal(&vsm);
  859. exceptions = vfp_single_multiply(&vsd, &vsn, &vsm, fpscr);
  860. vsd.sign = vfp_sign_negate(vsd.sign);
  861. return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, "fnmul");
  862. }
  863. /*
  864. * sd = sn + sm
  865. */
  866. static u32 vfp_single_fadd(int sd, int sn, s32 m, u32 fpscr)
  867. {
  868. struct vfp_single vsd, vsn, vsm;
  869. u32 exceptions;
  870. s32 n = vfp_get_float(sn);
  871. pr_debug("VFP: s%u = %08x\n", sn, n);
  872. /*
  873. * Unpack and normalise denormals.
  874. */
  875. vfp_single_unpack(&vsn, n);
  876. if (vsn.exponent == 0 && vsn.significand)
  877. vfp_single_normalise_denormal(&vsn);
  878. vfp_single_unpack(&vsm, m);
  879. if (vsm.exponent == 0 && vsm.significand)
  880. vfp_single_normalise_denormal(&vsm);
  881. exceptions = vfp_single_add(&vsd, &vsn, &vsm, fpscr);
  882. return vfp_single_normaliseround(sd, &vsd, fpscr, exceptions, "fadd");
  883. }
  884. /*
  885. * sd = sn - sm
  886. */
  887. static u32 vfp_single_fsub(int sd, int sn, s32 m, u32 fpscr)
  888. {
  889. /*
  890. * Subtraction is addition with one sign inverted.
  891. */
  892. return vfp_single_fadd(sd, sn, vfp_single_packed_negate(m), fpscr);
  893. }
  894. /*
  895. * sd = sn / sm
  896. */
  897. static u32 vfp_single_fdiv(int sd, int sn, s32 m, u32 fpscr)
  898. {
  899. struct vfp_single vsd, vsn, vsm;
  900. u32 exceptions = 0;
  901. s32 n = vfp_get_float(sn);
  902. int tm, tn;
  903. pr_debug("VFP: s%u = %08x\n", sn, n);
  904. vfp_single_unpack(&vsn, n);
  905. vfp_single_unpack(&vsm, m);
  906. vsd.sign = vsn.sign ^ vsm.sign;
  907. tn = vfp_single_type(&vsn);
  908. tm = vfp_single_type(&vsm);
  909. /*
  910. * Is n a NAN?
  911. */
  912. if (tn & VFP_NAN)
  913. goto vsn_nan;
  914. /*
  915. * Is m a NAN?
  916. */
  917. if (tm & VFP_NAN)
  918. goto vsm_nan;
  919. /*
  920. * If n and m are infinity, the result is invalid
  921. * If n and m are zero, the result is invalid
  922. */
  923. if (tm & tn & (VFP_INFINITY|VFP_ZERO))
  924. goto invalid;
  925. /*
  926. * If n is infinity, the result is infinity
  927. */
  928. if (tn & VFP_INFINITY)
  929. goto infinity;
  930. /*
  931. * If m is zero, raise div0 exception
  932. */
  933. if (tm & VFP_ZERO)
  934. goto divzero;
  935. /*
  936. * If m is infinity, or n is zero, the result is zero
  937. */
  938. if (tm & VFP_INFINITY || tn & VFP_ZERO)
  939. goto zero;
  940. if (tn & VFP_DENORMAL)
  941. vfp_single_normalise_denormal(&vsn);
  942. if (tm & VFP_DENORMAL)
  943. vfp_single_normalise_denormal(&vsm);
  944. /*
  945. * Ok, we have two numbers, we can perform division.
  946. */
  947. vsd.exponent = vsn.exponent - vsm.exponent + 127 - 1;
  948. vsm.significand <<= 1;
  949. if (vsm.significand <= (2 * vsn.significand)) {
  950. vsn.significand >>= 1;
  951. vsd.exponent++;
  952. }
  953. {
  954. u64 significand = (u64)vsn.significand << 32;
  955. do_div(significand, vsm.significand);
  956. vsd.significand = significand;
  957. }
  958. if ((vsd.significand & 0x3f) == 0)
  959. vsd.significand |= ((u64)vsm.significand * vsd.significand != (u64)vsn.significand << 32);
  960. return vfp_single_normaliseround(sd, &vsd, fpscr, 0, "fdiv");
  961. vsn_nan:
  962. exceptions = vfp_propagate_nan(&vsd, &vsn, &vsm, fpscr);
  963. pack:
  964. vfp_put_float(vfp_single_pack(&vsd), sd);
  965. return exceptions;
  966. vsm_nan:
  967. exceptions = vfp_propagate_nan(&vsd, &vsm, &vsn, fpscr);
  968. goto pack;
  969. zero:
  970. vsd.exponent = 0;
  971. vsd.significand = 0;
  972. goto pack;
  973. divzero:
  974. exceptions = FPSCR_DZC;
  975. infinity:
  976. vsd.exponent = 255;
  977. vsd.significand = 0;
  978. goto pack;
  979. invalid:
  980. vfp_put_float(vfp_single_pack(&vfp_single_default_qnan), sd);
  981. return FPSCR_IOC;
  982. }
  983. static struct op fops[16] = {
  984. [FOP_TO_IDX(FOP_FMAC)] = { vfp_single_fmac, 0 },
  985. [FOP_TO_IDX(FOP_FNMAC)] = { vfp_single_fnmac, 0 },
  986. [FOP_TO_IDX(FOP_FMSC)] = { vfp_single_fmsc, 0 },
  987. [FOP_TO_IDX(FOP_FNMSC)] = { vfp_single_fnmsc, 0 },
  988. [FOP_TO_IDX(FOP_FMUL)] = { vfp_single_fmul, 0 },
  989. [FOP_TO_IDX(FOP_FNMUL)] = { vfp_single_fnmul, 0 },
  990. [FOP_TO_IDX(FOP_FADD)] = { vfp_single_fadd, 0 },
  991. [FOP_TO_IDX(FOP_FSUB)] = { vfp_single_fsub, 0 },
  992. [FOP_TO_IDX(FOP_FDIV)] = { vfp_single_fdiv, 0 },
  993. };
  994. #define FREG_BANK(x) ((x) & 0x18)
  995. #define FREG_IDX(x) ((x) & 7)
  996. u32 vfp_single_cpdo(u32 inst, u32 fpscr)
  997. {
  998. u32 op = inst & FOP_MASK;
  999. u32 exceptions = 0;
  1000. unsigned int dest;
  1001. unsigned int sn = vfp_get_sn(inst);
  1002. unsigned int sm = vfp_get_sm(inst);
  1003. unsigned int vecitr, veclen, vecstride;
  1004. struct op *fop;
  1005. vecstride = 1 + ((fpscr & FPSCR_STRIDE_MASK) == FPSCR_STRIDE_MASK);
  1006. fop = (op == FOP_EXT) ? &fops_ext[FEXT_TO_IDX(inst)] : &fops[FOP_TO_IDX(op)];
  1007. /*
  1008. * fcvtsd takes a dN register number as destination, not sN.
  1009. * Technically, if bit 0 of dd is set, this is an invalid
  1010. * instruction. However, we ignore this for efficiency.
  1011. * It also only operates on scalars.
  1012. */
  1013. if (fop->flags & OP_DD)
  1014. dest = vfp_get_dd(inst);
  1015. else
  1016. dest = vfp_get_sd(inst);
  1017. /*
  1018. * If destination bank is zero, vector length is always '1'.
  1019. * ARM DDI0100F C5.1.3, C5.3.2.
  1020. */
  1021. if ((fop->flags & OP_SCALAR) || FREG_BANK(dest) == 0)
  1022. veclen = 0;
  1023. else
  1024. veclen = fpscr & FPSCR_LENGTH_MASK;
  1025. pr_debug("VFP: vecstride=%u veclen=%u\n", vecstride,
  1026. (veclen >> FPSCR_LENGTH_BIT) + 1);
  1027. if (!fop->fn)
  1028. goto invalid;
  1029. for (vecitr = 0; vecitr <= veclen; vecitr += 1 << FPSCR_LENGTH_BIT) {
  1030. s32 m = vfp_get_float(sm);
  1031. u32 except;
  1032. char type;
  1033. type = fop->flags & OP_DD ? 'd' : 's';
  1034. if (op == FOP_EXT)
  1035. pr_debug("VFP: itr%d (%c%u) = op[%u] (s%u=%08x)\n",
  1036. vecitr >> FPSCR_LENGTH_BIT, type, dest, sn,
  1037. sm, m);
  1038. else
  1039. pr_debug("VFP: itr%d (%c%u) = (s%u) op[%u] (s%u=%08x)\n",
  1040. vecitr >> FPSCR_LENGTH_BIT, type, dest, sn,
  1041. FOP_TO_IDX(op), sm, m);
  1042. except = fop->fn(dest, sn, m, fpscr);
  1043. pr_debug("VFP: itr%d: exceptions=%08x\n",
  1044. vecitr >> FPSCR_LENGTH_BIT, except);
  1045. exceptions |= except;
  1046. /*
  1047. * CHECK: It appears to be undefined whether we stop when
  1048. * we encounter an exception. We continue.
  1049. */
  1050. dest = FREG_BANK(dest) + ((FREG_IDX(dest) + vecstride) & 7);
  1051. sn = FREG_BANK(sn) + ((FREG_IDX(sn) + vecstride) & 7);
  1052. if (FREG_BANK(sm) != 0)
  1053. sm = FREG_BANK(sm) + ((FREG_IDX(sm) + vecstride) & 7);
  1054. }
  1055. return exceptions;
  1056. invalid:
  1057. return (u32)-1;
  1058. }