|
| 1 | +/*************************************************************************** |
| 2 | +* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and * |
| 3 | +* Martin Renou * |
| 4 | +* Copyright (c) QuantStack * |
| 5 | +* Copyright (c) Serge Guelton * |
| 6 | +* * |
| 7 | +* Distributed under the terms of the BSD 3-Clause License. * |
| 8 | +* * |
| 9 | +* The full license is in the file LICENSE, distributed with this software. * |
| 10 | +****************************************************************************/ |
| 11 | + |
| 12 | +// Few macros to select neon intrinsic function based on the scalar type |
| 13 | +#define NEON_DISPATCHER_BINARY(U8, S8, U16, S16, U32, S32, U64, S64, F32, type, arg1, arg2, result)\ |
| 14 | + if (std::is_same<type, uint8_t>::value) {\ |
| 15 | + result = U8(arg1, arg2);\ |
| 16 | + } else if(std::is_same<type, int8_t>::value) {\ |
| 17 | + result = S8(arg1, arg2);\ |
| 18 | + } else if(std::is_same<type, uint16_t>::value) {\ |
| 19 | + result = U16(arg1, arg2);\ |
| 20 | + } else if(std::is_same<type, int16_t>::value) {\ |
| 21 | + result = S16(arg1, arg2);\ |
| 22 | + } else if(std::is_same<type, uint32_t>::value) {\ |
| 23 | + result = U32(arg1, arg2);\ |
| 24 | + } else if(std::is_same<type, int32_t>::value) {\ |
| 25 | + result = S32(arg1, arg2);\ |
| 26 | + } else if(std::is_same<type, uint64_t>::value) {\ |
| 27 | + result = U64(arg1, arg2);\ |
| 28 | + } else if(std::is_same<type, int64_t>::value) {\ |
| 29 | + result = S64(arg1, arg2);\ |
| 30 | + } else if(std::is_same<type, float32_t>::value) {\ |
| 31 | + result = F32(arg1, arg2);\ |
| 32 | + } else {\ |
| 33 | + assert(false && "unsupported type");\ |
| 34 | + } |
| 35 | + |
| 36 | +#define NEON_DISPATCHER_BINARY_EXCLUDE_64(U8, S8, U16, S16, U32, S32, F32, type, arg1, arg2, result)\ |
| 37 | + if (std::is_same<type, uint8_t>::value) {\ |
| 38 | + result = U8(arg1, arg2);\ |
| 39 | + } else if(std::is_same<type, int8_t>::value) {\ |
| 40 | + result = S8(arg1, arg2);\ |
| 41 | + } else if(std::is_same<type, uint16_t>::value) {\ |
| 42 | + result = U16(arg1, arg2);\ |
| 43 | + } else if(std::is_same<type, int16_t>::value) {\ |
| 44 | + result = S16(arg1, arg2);\ |
| 45 | + } else if(std::is_same<type, uint32_t>::value) {\ |
| 46 | + result = U32(arg1, arg2);\ |
| 47 | + } else if(std::is_same<type, int32_t>::value) {\ |
| 48 | + result = S32(arg1, arg2);\ |
| 49 | + } else if(std::is_same<type, float32_t>::value) {\ |
| 50 | + result = F32(arg1, arg2);\ |
| 51 | + } else {\ |
| 52 | + assert(false && "unsupported type");\ |
| 53 | + } |
| 54 | + |
| 55 | +#define NEON_DISPATCHER_UNARY(U8, S8, U16, S16, U32, S32, U64, S64, F32, type, arg, result)\ |
| 56 | + if (std::is_same<type, uint8_t>::value) {\ |
| 57 | + result = U8(arg);\ |
| 58 | + } else if(std::is_same<type, int8_t>::value) {\ |
| 59 | + result = S8(arg);\ |
| 60 | + } else if(std::is_same<type, uint16_t>::value) {\ |
| 61 | + result = U16(arg);\ |
| 62 | + } else if(std::is_same<type, int16_t>::value) {\ |
| 63 | + result = S16(arg);\ |
| 64 | + } else if(std::is_same<type, uint32_t>::value) {\ |
| 65 | + result = U32(arg);\ |
| 66 | + } else if(std::is_same<type, int32_t>::value) {\ |
| 67 | + result = S32(arg);\ |
| 68 | + } else if(std::is_same<type, uint64_t>::value) {\ |
| 69 | + result = U64(arg);\ |
| 70 | + } else if(std::is_same<type, int64_t>::value) {\ |
| 71 | + result = S64(arg);\ |
| 72 | + } else if(std::is_same<type, float32_t>::value) {\ |
| 73 | + result = F32(arg);\ |
| 74 | + } else {\ |
| 75 | + assert(false && "unsupported type");\ |
| 76 | + } |
| 77 | + |
| 78 | +#define NEON_DISPATCHER_UNARY_EXCLUDE_64(U8, S8, U16, S16, U32, S32, F32, type, arg, result)\ |
| 79 | + if (std::is_same<type, uint8_t>::value) {\ |
| 80 | + result = U8(arg);\ |
| 81 | + } else if(std::is_same<type, int8_t>::value) {\ |
| 82 | + result = S8(arg);\ |
| 83 | + } else if(std::is_same<type, uint16_t>::value) {\ |
| 84 | + result = U16(arg);\ |
| 85 | + } else if(std::is_same<type, int16_t>::value) {\ |
| 86 | + result = S16(arg);\ |
| 87 | + } else if(std::is_same<type, uint32_t>::value) {\ |
| 88 | + result = U32(arg);\ |
| 89 | + } else if(std::is_same<type, int32_t>::value) {\ |
| 90 | + result = S32(arg);\ |
| 91 | + } else if(std::is_same<type, float32_t>::value) {\ |
| 92 | + result = F32(arg);\ |
| 93 | + } else {\ |
| 94 | + assert(false && "unsupported type");\ |
| 95 | + } |
| 96 | + |
| 97 | +#define NEON_DISPATCHER_SELECT(U8, S8, U16, S16, U32, S32, U64, S64, F32, type, cond, arg1, arg2, result)\ |
| 98 | + if (std::is_same<type, uint8_t>::value) {\ |
| 99 | + result = U8(cond, arg1, arg2);\ |
| 100 | + } else if(std::is_same<type, int8_t>::value) {\ |
| 101 | + result = S8(cond, arg1, arg2);\ |
| 102 | + } else if(std::is_same<type, uint16_t>::value) {\ |
| 103 | + result = U16(cond, arg1, arg2);\ |
| 104 | + } else if(std::is_same<type, int16_t>::value) {\ |
| 105 | + result = S16(cond, arg1, arg2);\ |
| 106 | + } else if(std::is_same<type, uint32_t>::value) {\ |
| 107 | + result = U32(cond, arg1, arg2);\ |
| 108 | + } else if(std::is_same<type, int32_t>::value) {\ |
| 109 | + result = S32(cond, arg1, arg2);\ |
| 110 | + } else if(std::is_same<type, uint64_t>::value) {\ |
| 111 | + result = U64(cond, arg1, arg2);\ |
| 112 | + } else if(std::is_same<type, int64_t>::value) {\ |
| 113 | + result = S64(cond, arg1, arg2);\ |
| 114 | + } else if(std::is_same<type, float32_t>::value) {\ |
| 115 | + result = F32(cond, arg1, arg2);\ |
| 116 | + } else {\ |
| 117 | + assert(false && "unsupported type");\ |
| 118 | + } |
| 119 | + |
0 commit comments