vfpsingle.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  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. }