|
17 | 17 | #include "qemu/main-loop.h"
|
18 | 18 | #include "qemu/timer.h"
|
19 | 19 | #include "qemu/bitops.h"
|
20 |
| -#include "qemu/crc32c.h" |
21 | 20 | #include "qemu/qemu-print.h"
|
22 | 21 | #include "exec/exec-all.h"
|
23 | 22 | #include "exec/translation-block.h"
|
24 |
| -#include <zlib.h> /* for crc32 */ |
25 | 23 | #include "hw/irq.h"
|
26 | 24 | #include "system/cpu-timers.h"
|
27 | 25 | #include "system/kvm.h"
|
@@ -10984,289 +10982,6 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
|
10984 | 10982 | };
|
10985 | 10983 | }
|
10986 | 10984 |
|
10987 |
| -/* |
10988 |
| - * Note that signed overflow is undefined in C. The following routines are |
10989 |
| - * careful to use unsigned types where modulo arithmetic is required. |
10990 |
| - * Failure to do so _will_ break on newer gcc. |
10991 |
| - */ |
10992 |
| - |
10993 |
| -/* Signed saturating arithmetic. */ |
10994 |
| - |
10995 |
| -/* Perform 16-bit signed saturating addition. */ |
10996 |
| -static inline uint16_t add16_sat(uint16_t a, uint16_t b) |
10997 |
| -{ |
10998 |
| - uint16_t res; |
10999 |
| - |
11000 |
| - res = a + b; |
11001 |
| - if (((res ^ a) & 0x8000) && !((a ^ b) & 0x8000)) { |
11002 |
| - if (a & 0x8000) { |
11003 |
| - res = 0x8000; |
11004 |
| - } else { |
11005 |
| - res = 0x7fff; |
11006 |
| - } |
11007 |
| - } |
11008 |
| - return res; |
11009 |
| -} |
11010 |
| - |
11011 |
| -/* Perform 8-bit signed saturating addition. */ |
11012 |
| -static inline uint8_t add8_sat(uint8_t a, uint8_t b) |
11013 |
| -{ |
11014 |
| - uint8_t res; |
11015 |
| - |
11016 |
| - res = a + b; |
11017 |
| - if (((res ^ a) & 0x80) && !((a ^ b) & 0x80)) { |
11018 |
| - if (a & 0x80) { |
11019 |
| - res = 0x80; |
11020 |
| - } else { |
11021 |
| - res = 0x7f; |
11022 |
| - } |
11023 |
| - } |
11024 |
| - return res; |
11025 |
| -} |
11026 |
| - |
11027 |
| -/* Perform 16-bit signed saturating subtraction. */ |
11028 |
| -static inline uint16_t sub16_sat(uint16_t a, uint16_t b) |
11029 |
| -{ |
11030 |
| - uint16_t res; |
11031 |
| - |
11032 |
| - res = a - b; |
11033 |
| - if (((res ^ a) & 0x8000) && ((a ^ b) & 0x8000)) { |
11034 |
| - if (a & 0x8000) { |
11035 |
| - res = 0x8000; |
11036 |
| - } else { |
11037 |
| - res = 0x7fff; |
11038 |
| - } |
11039 |
| - } |
11040 |
| - return res; |
11041 |
| -} |
11042 |
| - |
11043 |
| -/* Perform 8-bit signed saturating subtraction. */ |
11044 |
| -static inline uint8_t sub8_sat(uint8_t a, uint8_t b) |
11045 |
| -{ |
11046 |
| - uint8_t res; |
11047 |
| - |
11048 |
| - res = a - b; |
11049 |
| - if (((res ^ a) & 0x80) && ((a ^ b) & 0x80)) { |
11050 |
| - if (a & 0x80) { |
11051 |
| - res = 0x80; |
11052 |
| - } else { |
11053 |
| - res = 0x7f; |
11054 |
| - } |
11055 |
| - } |
11056 |
| - return res; |
11057 |
| -} |
11058 |
| - |
11059 |
| -#define ADD16(a, b, n) RESULT(add16_sat(a, b), n, 16); |
11060 |
| -#define SUB16(a, b, n) RESULT(sub16_sat(a, b), n, 16); |
11061 |
| -#define ADD8(a, b, n) RESULT(add8_sat(a, b), n, 8); |
11062 |
| -#define SUB8(a, b, n) RESULT(sub8_sat(a, b), n, 8); |
11063 |
| -#define PFX q |
11064 |
| - |
11065 |
| -#include "op_addsub.h" |
11066 |
| - |
11067 |
| -/* Unsigned saturating arithmetic. */ |
11068 |
| -static inline uint16_t add16_usat(uint16_t a, uint16_t b) |
11069 |
| -{ |
11070 |
| - uint16_t res; |
11071 |
| - res = a + b; |
11072 |
| - if (res < a) { |
11073 |
| - res = 0xffff; |
11074 |
| - } |
11075 |
| - return res; |
11076 |
| -} |
11077 |
| - |
11078 |
| -static inline uint16_t sub16_usat(uint16_t a, uint16_t b) |
11079 |
| -{ |
11080 |
| - if (a > b) { |
11081 |
| - return a - b; |
11082 |
| - } else { |
11083 |
| - return 0; |
11084 |
| - } |
11085 |
| -} |
11086 |
| - |
11087 |
| -static inline uint8_t add8_usat(uint8_t a, uint8_t b) |
11088 |
| -{ |
11089 |
| - uint8_t res; |
11090 |
| - res = a + b; |
11091 |
| - if (res < a) { |
11092 |
| - res = 0xff; |
11093 |
| - } |
11094 |
| - return res; |
11095 |
| -} |
11096 |
| - |
11097 |
| -static inline uint8_t sub8_usat(uint8_t a, uint8_t b) |
11098 |
| -{ |
11099 |
| - if (a > b) { |
11100 |
| - return a - b; |
11101 |
| - } else { |
11102 |
| - return 0; |
11103 |
| - } |
11104 |
| -} |
11105 |
| - |
11106 |
| -#define ADD16(a, b, n) RESULT(add16_usat(a, b), n, 16); |
11107 |
| -#define SUB16(a, b, n) RESULT(sub16_usat(a, b), n, 16); |
11108 |
| -#define ADD8(a, b, n) RESULT(add8_usat(a, b), n, 8); |
11109 |
| -#define SUB8(a, b, n) RESULT(sub8_usat(a, b), n, 8); |
11110 |
| -#define PFX uq |
11111 |
| - |
11112 |
| -#include "op_addsub.h" |
11113 |
| - |
11114 |
| -/* Signed modulo arithmetic. */ |
11115 |
| -#define SARITH16(a, b, n, op) do { \ |
11116 |
| - int32_t sum; \ |
11117 |
| - sum = (int32_t)(int16_t)(a) op (int32_t)(int16_t)(b); \ |
11118 |
| - RESULT(sum, n, 16); \ |
11119 |
| - if (sum >= 0) \ |
11120 |
| - ge |= 3 << (n * 2); \ |
11121 |
| - } while (0) |
11122 |
| - |
11123 |
| -#define SARITH8(a, b, n, op) do { \ |
11124 |
| - int32_t sum; \ |
11125 |
| - sum = (int32_t)(int8_t)(a) op (int32_t)(int8_t)(b); \ |
11126 |
| - RESULT(sum, n, 8); \ |
11127 |
| - if (sum >= 0) \ |
11128 |
| - ge |= 1 << n; \ |
11129 |
| - } while (0) |
11130 |
| - |
11131 |
| - |
11132 |
| -#define ADD16(a, b, n) SARITH16(a, b, n, +) |
11133 |
| -#define SUB16(a, b, n) SARITH16(a, b, n, -) |
11134 |
| -#define ADD8(a, b, n) SARITH8(a, b, n, +) |
11135 |
| -#define SUB8(a, b, n) SARITH8(a, b, n, -) |
11136 |
| -#define PFX s |
11137 |
| -#define ARITH_GE |
11138 |
| - |
11139 |
| -#include "op_addsub.h" |
11140 |
| - |
11141 |
| -/* Unsigned modulo arithmetic. */ |
11142 |
| -#define ADD16(a, b, n) do { \ |
11143 |
| - uint32_t sum; \ |
11144 |
| - sum = (uint32_t)(uint16_t)(a) + (uint32_t)(uint16_t)(b); \ |
11145 |
| - RESULT(sum, n, 16); \ |
11146 |
| - if ((sum >> 16) == 1) \ |
11147 |
| - ge |= 3 << (n * 2); \ |
11148 |
| - } while (0) |
11149 |
| - |
11150 |
| -#define ADD8(a, b, n) do { \ |
11151 |
| - uint32_t sum; \ |
11152 |
| - sum = (uint32_t)(uint8_t)(a) + (uint32_t)(uint8_t)(b); \ |
11153 |
| - RESULT(sum, n, 8); \ |
11154 |
| - if ((sum >> 8) == 1) \ |
11155 |
| - ge |= 1 << n; \ |
11156 |
| - } while (0) |
11157 |
| - |
11158 |
| -#define SUB16(a, b, n) do { \ |
11159 |
| - uint32_t sum; \ |
11160 |
| - sum = (uint32_t)(uint16_t)(a) - (uint32_t)(uint16_t)(b); \ |
11161 |
| - RESULT(sum, n, 16); \ |
11162 |
| - if ((sum >> 16) == 0) \ |
11163 |
| - ge |= 3 << (n * 2); \ |
11164 |
| - } while (0) |
11165 |
| - |
11166 |
| -#define SUB8(a, b, n) do { \ |
11167 |
| - uint32_t sum; \ |
11168 |
| - sum = (uint32_t)(uint8_t)(a) - (uint32_t)(uint8_t)(b); \ |
11169 |
| - RESULT(sum, n, 8); \ |
11170 |
| - if ((sum >> 8) == 0) \ |
11171 |
| - ge |= 1 << n; \ |
11172 |
| - } while (0) |
11173 |
| - |
11174 |
| -#define PFX u |
11175 |
| -#define ARITH_GE |
11176 |
| - |
11177 |
| -#include "op_addsub.h" |
11178 |
| - |
11179 |
| -/* Halved signed arithmetic. */ |
11180 |
| -#define ADD16(a, b, n) \ |
11181 |
| - RESULT(((int32_t)(int16_t)(a) + (int32_t)(int16_t)(b)) >> 1, n, 16) |
11182 |
| -#define SUB16(a, b, n) \ |
11183 |
| - RESULT(((int32_t)(int16_t)(a) - (int32_t)(int16_t)(b)) >> 1, n, 16) |
11184 |
| -#define ADD8(a, b, n) \ |
11185 |
| - RESULT(((int32_t)(int8_t)(a) + (int32_t)(int8_t)(b)) >> 1, n, 8) |
11186 |
| -#define SUB8(a, b, n) \ |
11187 |
| - RESULT(((int32_t)(int8_t)(a) - (int32_t)(int8_t)(b)) >> 1, n, 8) |
11188 |
| -#define PFX sh |
11189 |
| - |
11190 |
| -#include "op_addsub.h" |
11191 |
| - |
11192 |
| -/* Halved unsigned arithmetic. */ |
11193 |
| -#define ADD16(a, b, n) \ |
11194 |
| - RESULT(((uint32_t)(uint16_t)(a) + (uint32_t)(uint16_t)(b)) >> 1, n, 16) |
11195 |
| -#define SUB16(a, b, n) \ |
11196 |
| - RESULT(((uint32_t)(uint16_t)(a) - (uint32_t)(uint16_t)(b)) >> 1, n, 16) |
11197 |
| -#define ADD8(a, b, n) \ |
11198 |
| - RESULT(((uint32_t)(uint8_t)(a) + (uint32_t)(uint8_t)(b)) >> 1, n, 8) |
11199 |
| -#define SUB8(a, b, n) \ |
11200 |
| - RESULT(((uint32_t)(uint8_t)(a) - (uint32_t)(uint8_t)(b)) >> 1, n, 8) |
11201 |
| -#define PFX uh |
11202 |
| - |
11203 |
| -#include "op_addsub.h" |
11204 |
| - |
11205 |
| -static inline uint8_t do_usad(uint8_t a, uint8_t b) |
11206 |
| -{ |
11207 |
| - if (a > b) { |
11208 |
| - return a - b; |
11209 |
| - } else { |
11210 |
| - return b - a; |
11211 |
| - } |
11212 |
| -} |
11213 |
| - |
11214 |
| -/* Unsigned sum of absolute byte differences. */ |
11215 |
| -uint32_t HELPER(usad8)(uint32_t a, uint32_t b) |
11216 |
| -{ |
11217 |
| - uint32_t sum; |
11218 |
| - sum = do_usad(a, b); |
11219 |
| - sum += do_usad(a >> 8, b >> 8); |
11220 |
| - sum += do_usad(a >> 16, b >> 16); |
11221 |
| - sum += do_usad(a >> 24, b >> 24); |
11222 |
| - return sum; |
11223 |
| -} |
11224 |
| - |
11225 |
| -/* For ARMv6 SEL instruction. */ |
11226 |
| -uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b) |
11227 |
| -{ |
11228 |
| - uint32_t mask; |
11229 |
| - |
11230 |
| - mask = 0; |
11231 |
| - if (flags & 1) { |
11232 |
| - mask |= 0xff; |
11233 |
| - } |
11234 |
| - if (flags & 2) { |
11235 |
| - mask |= 0xff00; |
11236 |
| - } |
11237 |
| - if (flags & 4) { |
11238 |
| - mask |= 0xff0000; |
11239 |
| - } |
11240 |
| - if (flags & 8) { |
11241 |
| - mask |= 0xff000000; |
11242 |
| - } |
11243 |
| - return (a & mask) | (b & ~mask); |
11244 |
| -} |
11245 |
| - |
11246 |
| -/* |
11247 |
| - * CRC helpers. |
11248 |
| - * The upper bytes of val (above the number specified by 'bytes') must have |
11249 |
| - * been zeroed out by the caller. |
11250 |
| - */ |
11251 |
| -uint32_t HELPER(crc32)(uint32_t acc, uint32_t val, uint32_t bytes) |
11252 |
| -{ |
11253 |
| - uint8_t buf[4]; |
11254 |
| - |
11255 |
| - stl_le_p(buf, val); |
11256 |
| - |
11257 |
| - /* zlib crc32 converts the accumulator and output to one's complement. */ |
11258 |
| - return crc32(acc ^ 0xffffffff, buf, bytes) ^ 0xffffffff; |
11259 |
| -} |
11260 |
| - |
11261 |
| -uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes) |
11262 |
| -{ |
11263 |
| - uint8_t buf[4]; |
11264 |
| - |
11265 |
| - stl_le_p(buf, val); |
11266 |
| - |
11267 |
| - /* Linux crc32c converts the output to one's complement. */ |
11268 |
| - return crc32c(acc, buf, bytes) ^ 0xffffffff; |
11269 |
| -} |
11270 | 10985 |
|
11271 | 10986 | /*
|
11272 | 10987 | * Return the exception level to which FP-disabled exceptions should
|
|
0 commit comments