OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SaturatedArithmeticARM_h | 5 #ifndef SaturatedArithmeticARM_h |
6 #define SaturatedArithmeticARM_h | 6 #define SaturatedArithmeticARM_h |
7 | 7 |
8 #include "wtf/CPU.h" | 8 #include "wtf/CPU.h" |
9 #include <limits> | 9 #include <limits> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 15 matching lines...) Expand all Loading... |
26 int32_t result; | 26 int32_t result; |
27 | 27 |
28 asm("qsub %[output],%[first],%[second]" | 28 asm("qsub %[output],%[first],%[second]" |
29 : [output] "=r" (result) | 29 : [output] "=r" (result) |
30 : [first] "r" (a), | 30 : [first] "r" (a), |
31 [second] "r" (b)); | 31 [second] "r" (b)); |
32 | 32 |
33 return result; | 33 return result; |
34 } | 34 } |
35 | 35 |
| 36 ALWAYS_INLINE int32_t saturatedNegative(int32_t a) |
| 37 { |
| 38 return saturatedSubtraction(0, a); |
| 39 } |
| 40 |
36 inline int getMaxSaturatedSetResultForTesting(int FractionalShift) | 41 inline int getMaxSaturatedSetResultForTesting(int FractionalShift) |
37 { | 42 { |
38 // For ARM Asm version the set function maxes out to the biggest | 43 // For ARM Asm version the set function maxes out to the biggest |
39 // possible integer part with the fractional part zero'd out. | 44 // possible integer part with the fractional part zero'd out. |
40 // e.g. 0x7fffffc0. | 45 // e.g. 0x7fffffc0. |
41 return std::numeric_limits<int>::max() & ~((1 << FractionalShift)-1); | 46 return std::numeric_limits<int>::max() & ~((1 << FractionalShift)-1); |
42 } | 47 } |
43 | 48 |
44 inline int getMinSaturatedSetResultForTesting(int FractionalShift) | 49 inline int getMinSaturatedSetResultForTesting(int FractionalShift) |
45 { | 50 { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 "lsl %[output],%[shift]" | 103 "lsl %[output],%[shift]" |
99 : [output] "=r" (result) | 104 : [output] "=r" (result) |
100 : [value] "r" (value), | 105 : [value] "r" (value), |
101 [saturate] "n" (Saturate), | 106 [saturate] "n" (Saturate), |
102 [shift] "n" (FractionalShift)); | 107 [shift] "n" (FractionalShift)); |
103 | 108 |
104 return result; | 109 return result; |
105 } | 110 } |
106 | 111 |
107 #endif // SaturatedArithmeticARM_h | 112 #endif // SaturatedArithmeticARM_h |
OLD | NEW |