diff options
author | Richard Henderson <rth@twiddle.net> | 2015-09-23 10:43:48 -0700 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2015-10-07 20:03:14 +1100 |
commit | 9ff5b57c219f38f025b95ebf4b593b5d4e828b53 (patch) | |
tree | 4165e047f161bed4d92e10d0f65557f456fc9410 /target-tilegx/helper.c | |
parent | 0b4232f10895e863b1759a93ba0d0a1b3380dc31 (diff) |
target-tilegx: Implement complex multiply instructions
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target-tilegx/helper.c')
-rw-r--r-- | target-tilegx/helper.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/target-tilegx/helper.c b/target-tilegx/helper.c index cad5daeaae..36b287f84a 100644 --- a/target-tilegx/helper.c +++ b/target-tilegx/helper.c @@ -97,3 +97,43 @@ uint64_t helper_crc32_32(uint64_t accum, uint64_t input) /* zlib crc32 converts the accumulator and output to one's complement. */ return crc32(accum ^ 0xffffffff, buf, 4) ^ 0xffffffff; } + +uint64_t helper_cmula(uint64_t srcd, uint64_t srca, uint64_t srcb) +{ + uint32_t reala = (int16_t)srca; + uint32_t imaga = (int16_t)(srca >> 16); + uint32_t realb = (int16_t)srcb; + uint32_t imagb = (int16_t)(srcb >> 16); + uint32_t reald = srcd; + uint32_t imagd = srcd >> 32; + uint32_t realr = reala * realb - imaga * imagb + reald; + uint32_t imagr = reala * imagb + imaga * realb + imagd; + + return deposit64(realr, 32, 32, imagr); +} + +uint64_t helper_cmulaf(uint64_t srcd, uint64_t srca, uint64_t srcb) +{ + uint32_t reala = (int16_t)srca; + uint32_t imaga = (int16_t)(srca >> 16); + uint32_t realb = (int16_t)srcb; + uint32_t imagb = (int16_t)(srcb >> 16); + uint32_t reald = (int16_t)srcd; + uint32_t imagd = (int16_t)(srcd >> 16); + int32_t realr = reala * realb - imaga * imagb; + int32_t imagr = reala * imagb + imaga * realb; + + return deposit32((realr >> 15) + reald, 16, 16, (imagr >> 15) + imagd); +} + +uint64_t helper_cmul2(uint64_t srca, uint64_t srcb, int shift, int round) +{ + uint32_t reala = (int16_t)srca; + uint32_t imaga = (int16_t)(srca >> 16); + uint32_t realb = (int16_t)srcb; + uint32_t imagb = (int16_t)(srcb >> 16); + int32_t realr = reala * realb - imaga * imagb + round; + int32_t imagr = reala * imagb + imaga * realb + round; + + return deposit32(realr >> shift, 16, 16, imagr >> shift); +} |