Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | Copyright (c) 2009, 2010, 2011 STMicroelectronics |
| 4 | Written by Christophe Lyon |
| 5 | |
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | of this software and associated documentation files (the "Software"), to deal |
| 8 | in the Software without restriction, including without limitation the rights |
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | copies of the Software, and to permit persons to whom the Software is |
| 11 | furnished to do so, subject to the following conditions: |
| 12 | |
| 13 | The above copyright notice and this permission notice shall be included in |
| 14 | all copies or substantial portions of the Software. |
| 15 | |
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | THE SOFTWARE. |
| 23 | |
| 24 | */ |
| 25 | |
| 26 | #define INSN_NAME vqadd |
| 27 | #define TEST_MSG "VQADD/VQADDQ" |
| 28 | |
| 29 | /* Extra tests for functions requiring types larger than 64 bits to |
| 30 | compute saturation */ |
| 31 | void vqadd_64(void); |
| 32 | #define EXTRA_TESTS vqadd_64 |
| 33 | |
| 34 | #include "ref_v_binary_sat_op.c" |
| 35 | |
| 36 | void vqadd_64(void) |
| 37 | { |
| 38 | int i; |
| 39 | |
| 40 | DECL_VARIABLE_ALL_VARIANTS(vector1); |
| 41 | DECL_VARIABLE_ALL_VARIANTS(vector2); |
| 42 | DECL_VARIABLE_ALL_VARIANTS(vector_res); |
| 43 | |
| 44 | /* Initialize input "vector1" from "buffer" */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 45 | TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 46 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 47 | VDUP(vector2, , int, s, 64, 1, 0x0); |
| 48 | VDUP(vector2, , uint, u, 64, 1, 0x0); |
| 49 | VDUP(vector2, q, int, s, 64, 2, 0x0); |
| 50 | VDUP(vector2, q, uint, u, 64, 2, 0x0); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 51 | |
Christophe Lyon | 4a6e5cc | 2014-06-03 22:47:52 +0200 | [diff] [blame] | 52 | fprintf(ref_file, |
| 53 | "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 54 | TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1); |
| 55 | TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1); |
| 56 | TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2); |
| 57 | TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2); |
| 58 | |
| 59 | fprintf(ref_file, "\n64 bits saturation:\n"); |
| 60 | DUMP(TEST_MSG, int, 64, 1, PRIx64); |
| 61 | DUMP(TEST_MSG, uint, 64, 1, PRIx64); |
| 62 | DUMP(TEST_MSG, int, 64, 2, PRIx64); |
| 63 | DUMP(TEST_MSG, uint, 64, 2, PRIx64); |
| 64 | |
| 65 | /* Another set of tests */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 66 | VDUP(vector2, , int, s, 64, 1, 0x44); |
| 67 | VDUP(vector2, , uint, u, 64, 1, 0x88); |
| 68 | VDUP(vector2, q, int, s, 64, 2, 0x44); |
| 69 | VDUP(vector2, q, uint, u, 64, 2, 0x88); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 70 | |
Christophe Lyon | 4a6e5cc | 2014-06-03 22:47:52 +0200 | [diff] [blame] | 71 | fprintf(ref_file, |
| 72 | "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 73 | TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1); |
| 74 | TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1); |
| 75 | TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2); |
| 76 | TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2); |
| 77 | |
| 78 | DUMP(TEST_MSG, int, 64, 1, PRIx64); |
| 79 | DUMP(TEST_MSG, uint, 64, 1, PRIx64); |
| 80 | DUMP(TEST_MSG, int, 64, 2, PRIx64); |
| 81 | DUMP(TEST_MSG, uint, 64, 2, PRIx64); |
| 82 | |
| 83 | /* Another set of tests */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 84 | VDUP(vector2, , int, s, 64, 1, 0x8000000000000003LL); |
| 85 | VDUP(vector2, , uint, u, 64, 1, 0x88); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 86 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 87 | VDUP(vector1, q, int, s, 64, 2, 0x4000000000000000LL); |
| 88 | VDUP(vector2, q, int, s, 64, 2, 0x4000000000000000LL); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 89 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 90 | VDUP(vector2, q, uint, u, 64, 2, 0x22); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 91 | |
Christophe Lyon | 4a6e5cc | 2014-06-03 22:47:52 +0200 | [diff] [blame] | 92 | fprintf(ref_file, |
| 93 | "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 94 | TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1); |
| 95 | TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1); |
| 96 | TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2); |
| 97 | TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2); |
| 98 | |
| 99 | DUMP(TEST_MSG, int, 64, 1, PRIx64); |
| 100 | DUMP(TEST_MSG, uint, 64, 1, PRIx64); |
| 101 | DUMP(TEST_MSG, int, 64, 2, PRIx64); |
| 102 | DUMP(TEST_MSG, uint, 64, 2, PRIx64); |
| 103 | |
| 104 | /* To improve coverage, check saturation with less than 64 bits too */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 105 | VDUP(vector2, , int, s, 8, 8, 0x81); |
| 106 | VDUP(vector2, , int, s, 16, 4, 0x8001); |
| 107 | VDUP(vector2, , int, s, 32, 2, 0x80000001); |
| 108 | VDUP(vector2, q, int, s, 8, 16, 0x81); |
| 109 | VDUP(vector2, q, int, s, 16, 8, 0x8001); |
| 110 | VDUP(vector2, q, int, s, 32, 4, 0x80000001); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 111 | |
| 112 | fprintf(ref_file, "\nless than 64 bits saturation:\n"); |
| 113 | TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8); |
| 114 | TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4); |
| 115 | TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2); |
| 116 | TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16); |
| 117 | TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8); |
| 118 | TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4); |
| 119 | |
| 120 | DUMP(TEST_MSG, int, 8, 8, PRIx8); |
| 121 | DUMP(TEST_MSG, int, 16, 4, PRIx16); |
| 122 | DUMP(TEST_MSG, int, 32, 2, PRIx32); |
| 123 | DUMP(TEST_MSG, int, 8, 16, PRIx8); |
| 124 | DUMP(TEST_MSG, int, 16, 8, PRIx16); |
| 125 | DUMP(TEST_MSG, int, 32, 4, PRIx32); |
| 126 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 127 | VDUP(vector1, , uint, u, 8, 8, 0xF0); |
| 128 | VDUP(vector1, , uint, u, 16, 4, 0xFFF0); |
| 129 | VDUP(vector1, , uint, u, 32, 2, 0xFFFFFFF0); |
| 130 | VDUP(vector1, q, uint, u, 8, 16, 0xF0); |
| 131 | VDUP(vector1, q, uint, u, 16, 8, 0xFFF0); |
| 132 | VDUP(vector1, q, uint, u, 32, 4, 0xFFFFFFF0); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 133 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 134 | VDUP(vector2, , uint, u, 8, 8, 0x20); |
| 135 | VDUP(vector2, , uint, u, 16, 4, 0x20); |
| 136 | VDUP(vector2, , uint, u, 32, 2, 0x20); |
| 137 | VDUP(vector2, q, uint, u, 8, 16, 0x20); |
| 138 | VDUP(vector2, q, uint, u, 16, 8, 0x20); |
| 139 | VDUP(vector2, q, uint, u, 32, 4, 0x20); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 140 | |
Christophe Lyon | 4a6e5cc | 2014-06-03 22:47:52 +0200 | [diff] [blame] | 141 | fprintf(ref_file, |
| 142 | "\n%s less than 64 bits saturation cumulative saturation output:\n", |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 143 | TEST_MSG); |
| 144 | TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8); |
| 145 | TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4); |
| 146 | TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2); |
| 147 | TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16); |
| 148 | TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8); |
| 149 | TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4); |
| 150 | |
| 151 | DUMP(TEST_MSG, uint, 8, 8, PRIx8); |
| 152 | DUMP(TEST_MSG, uint, 16, 4, PRIx16); |
| 153 | DUMP(TEST_MSG, uint, 32, 2, PRIx32); |
| 154 | DUMP(TEST_MSG, uint, 8, 16, PRIx8); |
| 155 | DUMP(TEST_MSG, uint, 16, 8, PRIx16); |
| 156 | DUMP(TEST_MSG, uint, 32, 4, PRIx32); |
| 157 | } |