39 using namespace MipsISA;
47 for (
int i = 0;
i < 16;
i++) {
51 result |= (value & 1 <<
i) << -
shift;
53 result |= (value & 1 <<
i) >>
shift;
63 int64_t svalue = (int64_t)value;
70 }
else if (svalue < (int64_t)
FIXED_SMIN[fmt]) {
79 }
else if (svalue < (int64_t)
FIXED_UMIN[fmt]) {
86 return (uint64_t)svalue;
93 int64_t svalue = (int64_t)value;
109 return (uint64_t)svalue;
116 uint64_t sign = uint64_t(1) << (signpos - 1);
117 uint64_t ones = ~(0ULL);
120 value |= (ones << signpos);
122 value &= (ones >> (64 - signpos));
130 return value += 1ULL << (lsbpos - 1);
144 for (
int i = 0;
i < nvals;
i++) {
145 svalue = (int64_t)a_values[
i];
150 }
else if (svalue < 0) {
151 a_values[
i] = uint64_t(0 - svalue);
166 int32_t sign, uint32_t *dspctl)
177 for (
int i = 0;
i < nvals;
i++)
208 for (
int i = 0;
i < nvals;
i++) {
212 a_values[
i] = (a_values[
i] + b_values[
i]) >> 1;
222 int32_t sign, uint32_t *dspctl)
233 for (
int i = 0;
i < nvals;
i++) {
263 for (
int i = 0;
i < nvals;
i++)
268 a_values[
i] = (a_values[
i] - b_values[
i]) >> 1;
278 int32_t sign, uint32_t *dspctl)
288 for (
int i = 0;
i < nvals;
i++)
316 for (
int i = 0;
i < nvals;
i++)
317 a_values[
i] = a_values[
i] >>
sa;
326 int32_t sign, uint32_t *dspctl)
336 for (
int i = 0;
i < nvals;
i++) {
340 a_values[
i] = a_values[
i] >>
sa;
350 int32_t round, uint32_t *dspctl)
363 for (
int i = 0;
i < nvals;
i++) {
368 temp = (int64_t)(a_values[
i] * b_values[
i]) >> (
sa - 1);
402 for (
int i = 0;
i < nvals;
i++)
435 for (
int i = 0;
i < nvals;
i++)
440 for (
int i = 0;
i < nvals;
i++)
465 memset(c_values, 0,
sizeof(c_values));
472 for (
int i = 0;
i < nvals;
i++)
477 for (
int i = 0;
i < nvals;
i++)
494 int32_t infmt, int32_t outfmt, int32_t postsat, int32_t
mode,
507 for (
int i = 0;
i < nvals;
i++) {
510 if (a_values[nvals - 1 -
i] ==
FIXED_SMIN[infmt] &&
516 result += a_values[nvals - 1 -
i] * b_values[
i] << 1;
524 result += a_values[
i] * b_values[
i] << 1;
532 int signa =
bits(dspac, 63, 63);
533 int signb =
bits(result, 63, 63);
535 temp = dspac + result;
537 if (signa == signb &&
bits(temp, 63, 63) != signa) {
561 int32_t infmt, int32_t outfmt, int32_t postsat, int32_t
mode,
574 for (
int i = 0;
i < nvals;
i++) {
577 if (a_values[nvals - 1 -
i] ==
FIXED_SMIN[infmt] &&
582 result += a_values[nvals - 1 -
i] * b_values[
i] << 1;
591 result += a_values[
i] * b_values[
i] << 1;
599 int signa =
bits(dspac, 63, 63);
600 int signb =
bits(-result, 63, 63);
602 temp = dspac - result;
604 if (signa == signb &&
bits(temp, 63, 63) != signa) {
628 int32_t fmt, int32_t sign, int32_t
mode)
637 for (
int i = 0;
i < 2;
i++) {
640 dspac += a_values[nvals - 1 -
i] * b_values[nvals - 1 -
i];
643 dspac += a_values[nvals - 3 -
i] * b_values[nvals - 3 -
i];
646 dspac += a_values[nvals - 1 -
i] * b_values[
i];
656 int32_t fmt, int32_t sign, int32_t
mode)
665 for (
int i = 0;
i < 2;
i++) {
668 dspac -= a_values[nvals - 1 -
i] * b_values[nvals - 1 -
i];
671 dspac -= a_values[nvals - 3 -
i] * b_values[nvals - 3 -
i];
674 dspac -= a_values[nvals - 1 -
i] * b_values[
i];
684 int32_t fmt, int32_t
mode, int32_t saturate, uint32_t *dspctl)
695 for (
int i = 0;
i < nvals;
i++) {
698 temp = a_values[
i + 1] * b_values[
i + 1] << 1;
706 temp = a_values[
i] * b_values[
i] << 1;
735 dspac += a_values[1] * b_values[1] - a_values[0] * b_values[0];
742 int32_t fmt, uint32_t *dspctl)
747 int64_t temp[2] = {0, 0};
753 for (
int i = nvals - 1;
i > -1;
i--) {
754 temp[
i] = a_values[
i] * b_values[
i] << 1;
761 dspac += temp[1] - temp[0];
781 for (
int i = 0;
i < nvals;
i++) {
786 cc = (a_values[
i] == b_values[
i]);
789 cc = (a_values[
i] < b_values[
i]);
792 cc = (a_values[
i] <= b_values[
i]);
813 for (
int i = 0;
i < nvals;
i++) {
818 cc = (a_values[
i] == b_values[
i]);
821 cc = (a_values[
i] < b_values[
i]);
824 cc = (a_values[
i] <= b_values[
i]);
847 for (
int i = 0;
i < nvals;
i++) {
852 cc = (a_values[
i] == b_values[
i]);
855 cc = (a_values[
i] < b_values[
i]);
858 cc = (a_values[
i] <= b_values[
i]);
873 int32_t outsign, int32_t
mode)
891 for (
int i = 0;
i<noutvals;
i++) {
894 out_values[
i] = in_values[
i + (ninvals >> 1)] <<
sa;
897 out_values[
i] = in_values[
i] <<
sa;
900 out_values[
i] = in_values[(
i << 1) + 1] <<
sa;
903 out_values[
i] = in_values[
i << 1] <<
sa;
908 simdPack(out_values, &result, outfmt);
925 for (
int i = 0;
i<2;
i++) {
955 fmt + 1,
SIGNED, &ouflag);
957 fmt + 1,
SIGNED, &ouflag);
959 simdPack(r_values, &result, fmt + 1);
980 for (
int i = 0;
i < nvals;
i++) {
985 c_values[
i] = b_values[
i] >>
sa;
986 c_values[
i + 1] = a_values[
i] >>
sa;
990 simdPack(c_values, &result, fmt + 1);
1007 for (
int i = 0;
i < nvals;
i++) {
1009 if (
bits(*dspctl, condbit, condbit) == 1)
1010 c_values[
i] = a_values[
i];
1012 c_values[
i] = b_values[
i];
1031 c_values[0] = b_values[1];
1032 c_values[1] = a_values[0];
1041 int32_t saturate, uint32_t *dspctl)
1044 uint32_t ouflag = 0;
1053 if (dspac > 0 && temp < 0) {
1069 *dspctl =
insertBits(*dspctl, 23, 23, ouflag);
1074 result = (int32_t)temp;
1076 result = (int32_t)temp;
1088 pos =
bits(*dspctl, 5, 0);
1089 size =
bits(size, 4, 0);
1091 if (pos - (size + 1) >= -1) {
1092 result =
bits(dspac, pos, pos - size);
1108 pos =
bits(*dspctl, 5, 0);
1109 size =
bits(size, 4, 0);
1111 if (pos - (size + 1) >= -1) {
1112 result =
bits(dspac, pos, pos - size);
1114 if (pos - (size + 1) >= 0)
1115 *dspctl =
insertBits(*dspctl, 5, 0, pos - (size + 1));
1116 else if ((pos - (size + 1)) == -1)
1134 for (
int i = 0;
i < nvals;
i++)
1135 *
reg |= (int32_t)
bits(values_ptr[
i], nbits - 1, 0) << nbits *
i;
1146 for (
int i = 0;
i < nvals;
i++) {
1147 uint64_t tmp = (uint64_t)
bits(
reg, nbits * (
i + 1) - 1, nbits *
i);
1152 for (
int i = 0;
i < nvals;
i++) {
1154 (uint64_t)
bits(
reg, nbits * (
i + 1) - 1, nbits *
i);
1189 return *dspctl & fmask;