39 using namespace MipsISA;
48 for (
int i = 0;
i < 16;
i++) {
52 result |= (value & 1 <<
i) << -shift;
54 result |= (value & 1 <<
i) >> shift;
64 int64_t svalue = (int64_t)value;
71 }
else if (svalue < (int64_t)
FIXED_SMIN[fmt]) {
80 }
else if (svalue < (int64_t)
FIXED_UMIN[fmt]) {
87 return (uint64_t)svalue;
94 int64_t svalue = (int64_t)value;
110 return (uint64_t)svalue;
117 uint64_t sign = uint64_t(1) << (signpos - 1);
118 uint64_t ones = ~(0
ULL);
121 value |= (ones << signpos);
123 value &= (ones >> (64 - signpos));
131 return value +=
ULL(1) << (lsbpos - 1);
145 for (
int i = 0;
i < nvals;
i++) {
146 svalue = (int64_t)a_values[
i];
151 }
else if (svalue < 0) {
152 a_values[
i] = uint64_t(0 - svalue);
167 int32_t sign, uint32_t *dspctl)
178 for (
int i = 0;
i < nvals;
i++)
209 for (
int i = 0;
i < nvals;
i++) {
213 a_values[
i] = (a_values[
i] + b_values[
i]) >> 1;
223 int32_t sign, uint32_t *dspctl)
234 for (
int i = 0;
i < nvals;
i++) {
264 for (
int i = 0;
i < nvals;
i++)
269 a_values[
i] = (a_values[
i] - b_values[
i]) >> 1;
279 int32_t sign, uint32_t *dspctl)
289 for (
int i = 0;
i < nvals;
i++)
292 a_values[
i] =
dspSaturate(a_values[
i] << sa, fmt, sign, &ouflag);
317 for (
int i = 0;
i < nvals;
i++)
318 a_values[
i] = a_values[
i] >> sa;
327 int32_t sign, uint32_t *dspctl)
337 for (
int i = 0;
i < nvals;
i++) {
341 a_values[
i] = a_values[
i] >>
sa;
351 int32_t round, uint32_t *dspctl)
364 for (
int i = 0;
i < nvals;
i++) {
369 temp = (int64_t)(a_values[
i] * b_values[
i]) >> (sa - 1);
403 for (
int i = 0;
i < nvals;
i++)
436 for (
int i = 0;
i < nvals;
i++)
441 for (
int i = 0; i < nvals; i++)
466 memset(c_values, 0,
sizeof(c_values));
473 for (
int i = 0;
i < nvals;
i++)
478 for (
int i = 0;
i < nvals;
i++)
495 int32_t infmt, int32_t outfmt, int32_t postsat, int32_t
mode,
508 for (
int i = 0;
i < nvals;
i++) {
511 if (a_values[nvals - 1 -
i] ==
FIXED_SMIN[infmt] &&
517 result += a_values[nvals - 1 -
i] * b_values[
i] << 1;
525 result += a_values[
i] * b_values[
i] << 1;
533 int signa =
bits(dspac, 63, 63);
534 int signb =
bits(result, 63, 63);
536 temp = dspac + result;
538 if (signa == signb &&
bits(temp, 63, 63) != signa) {
555 *dspctl =
insertBits(*dspctl, 16 + ac, 16 + ac, 1);
562 int32_t infmt, int32_t outfmt, int32_t postsat, int32_t
mode,
575 for (
int i = 0;
i < nvals;
i++) {
578 if (a_values[nvals - 1 -
i] ==
FIXED_SMIN[infmt] &&
583 result += a_values[nvals - 1 -
i] * b_values[
i] << 1;
592 result += a_values[
i] * b_values[
i] << 1;
600 int signa =
bits(dspac, 63, 63);
601 int signb =
bits(-result, 63, 63);
603 temp = dspac - result;
605 if (signa == signb &&
bits(temp, 63, 63) != signa) {
622 *dspctl =
insertBits(*dspctl, 16 + ac, 16 + ac, 1);
629 int32_t fmt, int32_t sign, int32_t
mode)
638 for (
int i = 0;
i < 2;
i++) {
641 dspac += a_values[nvals - 1 -
i] * b_values[nvals - 1 -
i];
644 dspac += a_values[nvals - 3 -
i] * b_values[nvals - 3 -
i];
647 dspac += a_values[nvals - 1 -
i] * b_values[
i];
657 int32_t fmt, int32_t sign, int32_t
mode)
666 for (
int i = 0;
i < 2;
i++) {
669 dspac -= a_values[nvals - 1 -
i] * b_values[nvals - 1 -
i];
672 dspac -= a_values[nvals - 3 -
i] * b_values[nvals - 3 -
i];
675 dspac -= a_values[nvals - 1 -
i] * b_values[
i];
685 int32_t fmt, int32_t
mode, int32_t saturate, uint32_t *dspctl)
696 for (
int i = 0;
i < nvals;
i++) {
699 temp = a_values[
i + 1] * b_values[
i + 1] << 1;
707 temp = a_values[
i] * b_values[
i] << 1;
721 *dspctl =
insertBits(*dspctl, 16 + ac, 16 + ac, 1);
736 dspac += a_values[1] * b_values[1] - a_values[0] * b_values[0];
743 int32_t fmt, uint32_t *dspctl)
748 int64_t temp[2] = {0, 0};
754 for (
int i = nvals - 1;
i > -1;
i--) {
755 temp[
i] = a_values[
i] * b_values[
i] << 1;
762 dspac += temp[1] - temp[0];
765 *dspctl =
insertBits(*dspctl, 16 + ac, 16 + ac, 1);
782 for (
int i = 0;
i < nvals;
i++) {
787 cc = (a_values[
i] == b_values[
i]);
790 cc = (a_values[
i] < b_values[
i]);
793 cc = (a_values[
i] <= b_values[
i]);
814 for (
int i = 0;
i < nvals;
i++) {
819 cc = (a_values[
i] == b_values[
i]);
822 cc = (a_values[
i] < b_values[
i]);
825 cc = (a_values[
i] <= b_values[
i]);
848 for (
int i = 0;
i < nvals;
i++) {
853 cc = (a_values[
i] == b_values[
i]);
856 cc = (a_values[
i] < b_values[
i]);
859 cc = (a_values[
i] <= b_values[
i]);
874 int32_t outsign, int32_t
mode)
892 for (
int i = 0;
i<noutvals;
i++) {
895 out_values[
i] = in_values[
i + (ninvals >> 1)] << sa;
898 out_values[
i] = in_values[
i] <<
sa;
901 out_values[
i] = in_values[(
i << 1) + 1] << sa;
904 out_values[
i] = in_values[
i << 1] <<
sa;
909 simdPack(out_values, &result, outfmt);
926 for (
int i = 0;
i<2;
i++) {
956 fmt + 1,
SIGNED, &ouflag);
958 fmt + 1,
SIGNED, &ouflag);
960 simdPack(r_values, &result, fmt + 1);
981 for (
int i = 0;
i < nvals;
i++) {
986 c_values[
i] = b_values[
i] >>
sa;
987 c_values[
i + 1] = a_values[
i] >>
sa;
991 simdPack(c_values, &result, fmt + 1);
1008 for (
int i = 0;
i < nvals;
i++) {
1010 if (
bits(*dspctl, condbit, condbit) == 1)
1011 c_values[
i] = a_values[
i];
1013 c_values[
i] = b_values[
i];
1032 c_values[0] = b_values[1];
1033 c_values[1] = a_values[0];
1042 int32_t saturate, uint32_t *dspctl)
1045 uint32_t ouflag = 0;
1048 sa =
bits(sa, 4, 0);
1054 if (dspac > 0 && temp < 0) {
1070 *dspctl =
insertBits(*dspctl, 23, 23, ouflag);
1075 result = (int32_t)temp;
1077 result = (int32_t)temp;
1089 pos =
bits(*dspctl, 5, 0);
1090 size =
bits(size, 4, 0);
1092 if (pos - (size + 1) >= -1) {
1093 result =
bits(dspac, pos, pos - size);
1109 pos =
bits(*dspctl, 5, 0);
1110 size =
bits(size, 4, 0);
1112 if (pos - (size + 1) >= -1) {
1113 result =
bits(dspac, pos, pos - size);
1115 if (pos - (size + 1) >= 0)
1116 *dspctl =
insertBits(*dspctl, 5, 0, pos - (size + 1));
1117 else if ((pos - (size + 1)) == -1)
1135 for (
int i = 0;
i < nvals;
i++)
1136 *reg |= (int32_t)
bits(values_ptr[
i], nbits - 1, 0) << nbits *
i;
1147 for (
int i = 0;
i < nvals;
i++) {
1148 uint64_t tmp = (uint64_t)
bits(reg, nbits * (
i + 1) - 1, nbits *
i);
1153 for (
int i = 0;
i < nvals;
i++) {
1155 (uint64_t)
bits(reg, nbits * (
i + 1) - 1, nbits *
i);
1190 return *dspctl & fmask;
const uint32_t SIMD_MAX_VALS
void dspCmp(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op, uint32_t *dspctl)
int32_t dspShll(int32_t a, uint32_t sa, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
const uint32_t SIMD_LOG2N[SIMD_NUM_FMTS]
int64_t dspDpa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, int32_t sign, int32_t mode)
uint64_t dspSaturate(uint64_t value, int32_t fmt, int32_t sign, uint32_t *overflow)
int32_t dspPrecrSra(int32_t a, int32_t b, int32_t sa, int32_t fmt, int32_t round)
int32_t dspExtp(int64_t dspac, int32_t size, uint32_t *dspctl)
int32_t dspPick(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl)
const uint32_t SIMD_NVALS[SIMD_NUM_FMTS]
uint64_t checkOverflow(uint64_t value, int32_t fmt, int32_t sign, uint32_t *overflow)
int64_t dspMaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, int32_t mode, int32_t saturate, uint32_t *dspctl)
int64_t dspDpsq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode, uint32_t *dspctl)
int32_t dspAbs(int32_t a, int32_t fmt, uint32_t *dspctl)
int32_t dspMulq(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t round, uint32_t *dspctl)
int32_t dspMul(int32_t a, int32_t b, int32_t fmt, int32_t saturate, uint32_t *dspctl)
int32_t dspExtpd(int64_t dspac, int32_t size, uint32_t *dspctl)
uint64_t signExtend(uint64_t value, int32_t signpos)
int32_t dspPrecrq(int32_t a, int32_t b, int32_t fmt, uint32_t *dspctl)
const uint32_t DSP_CTL_POS[DSP_NUM_FIELDS]
void simdUnpack(int32_t reg, uint64_t *values_ptr, int32_t fmt, int32_t sign)
const uint32_t DSP_CTL_MASK[DSP_NUM_FIELDS]
int32_t dspPrece(int32_t a, int32_t infmt, int32_t insign, int32_t outfmt, int32_t outsign, int32_t mode)
int32_t dspCmpg(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op)
void simdPack(uint64_t *values_ptr, int32_t *reg, int32_t fmt)
int32_t dspSub(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
const uint64_t FIXED_UMAX[SIMD_NUM_FMTS]
T insertBits(T val, int first, int last, B bit_val)
Return val with bits first to last set to bit_val.
int32_t dspAdd(int32_t a, int32_t b, int32_t fmt, int32_t saturate, int32_t sign, uint32_t *dspctl)
uint32_t readDSPControl(uint32_t *dspctl, uint32_t mask)
int32_t dspPrecrqu(int32_t a, int32_t b, uint32_t *dspctl)
int32_t dspShra(int32_t a, uint32_t sa, int32_t fmt, int32_t round, int32_t sign, uint32_t *dspctl)
int32_t dspCmpgd(int32_t a, int32_t b, int32_t fmt, int32_t sign, int32_t op, uint32_t *dspctl)
#define ULL(N)
uint64_t constant
void writeDSPControl(uint32_t *dspctl, uint32_t value, uint32_t mask)
int32_t dspShrl(int32_t a, uint32_t sa, int32_t fmt, int32_t sign)
const uint64_t FIXED_SMIN[SIMD_NUM_FMTS]
int64_t dspDpaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t infmt, int32_t outfmt, int32_t postsat, int32_t mode, uint32_t *dspctl)
int32_t bitrev(int32_t value)
const uint32_t SIMD_NBITS[SIMD_NUM_FMTS]
int64_t dspMulsaq(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, uint32_t *dspctl)
int32_t dspMuleq(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl)
int32_t dspSubh(int32_t a, int32_t b, int32_t fmt, int32_t round, int32_t sign)
const uint64_t FIXED_UMIN[SIMD_NUM_FMTS]
uint64_t addHalfLsb(uint64_t value, int32_t lsbpos)
const uint64_t FIXED_SMAX[SIMD_NUM_FMTS]
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
int64_t dspMulsa(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt)
int32_t dspExtr(int64_t dspac, int32_t fmt, int32_t sa, int32_t round, int32_t saturate, uint32_t *dspctl)
int64_t dspDps(int64_t dspac, int32_t a, int32_t b, int32_t ac, int32_t fmt, int32_t sign, int32_t mode)
int32_t dspMuleu(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl)
int32_t dspAddh(int32_t a, int32_t b, int32_t fmt, int32_t round, int32_t sign)
int32_t dspPack(int32_t a, int32_t b, int32_t fmt)