summaryrefslogtreecommitdiffstats
path: root/src/core/arm/skyeye_common/armsupp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/arm/skyeye_common/armsupp.cpp')
-rw-r--r--src/core/arm/skyeye_common/armsupp.cpp56
1 files changed, 19 insertions, 37 deletions
diff --git a/src/core/arm/skyeye_common/armsupp.cpp b/src/core/arm/skyeye_common/armsupp.cpp
index 883713e86..06aa1b075 100644
--- a/src/core/arm/skyeye_common/armsupp.cpp
+++ b/src/core/arm/skyeye_common/armsupp.cpp
@@ -16,14 +16,12 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "common/logging/log.h"
-
#include "core/arm/skyeye_common/arm_regformat.h"
#include "core/arm/skyeye_common/armstate.h"
#include "core/arm/skyeye_common/armsupp.h"
// Unsigned sum of absolute difference
-u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right)
-{
+u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right) {
if (left > right)
return left - right;
@@ -31,8 +29,8 @@ u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right)
}
// Add with carry, indicates if a carry-out or signed overflow occurred.
-u32 AddWithCarry(u32 left, u32 right, u32 carry_in, bool* carry_out_occurred, bool* overflow_occurred)
-{
+u32 AddWithCarry(u32 left, u32 right, u32 carry_in, bool* carry_out_occurred,
+ bool* overflow_occurred) {
u64 unsigned_sum = (u64)left + (u64)right + (u64)carry_in;
s64 signed_sum = (s64)(s32)left + (s64)(s32)right + (s64)carry_in;
u64 result = (unsigned_sum & 0xFFFFFFFF);
@@ -47,22 +45,17 @@ u32 AddWithCarry(u32 left, u32 right, u32 carry_in, bool* carry_out_occurred, bo
}
// Compute whether an addition of A and B, giving RESULT, overflowed.
-bool AddOverflow(u32 a, u32 b, u32 result)
-{
- return ((NEG(a) && NEG(b) && POS(result)) ||
- (POS(a) && POS(b) && NEG(result)));
+bool AddOverflow(u32 a, u32 b, u32 result) {
+ return ((NEG(a) && NEG(b) && POS(result)) || (POS(a) && POS(b) && NEG(result)));
}
// Compute whether a subtraction of A and B, giving RESULT, overflowed.
-bool SubOverflow(u32 a, u32 b, u32 result)
-{
- return ((NEG(a) && POS(b) && POS(result)) ||
- (POS(a) && NEG(b) && NEG(result)));
+bool SubOverflow(u32 a, u32 b, u32 result) {
+ return ((NEG(a) && POS(b) && POS(result)) || (POS(a) && NEG(b) && NEG(result)));
}
// Returns true if the Q flag should be set as a result of overflow.
-bool ARMul_AddOverflowQ(u32 a, u32 b)
-{
+bool ARMul_AddOverflowQ(u32 a, u32 b) {
u32 result = a + b;
if (((result ^ a) & (u32)0x80000000) && ((a ^ b) & (u32)0x80000000) == 0)
return true;
@@ -71,8 +64,7 @@ bool ARMul_AddOverflowQ(u32 a, u32 b)
}
// 8-bit signed saturated addition
-u8 ARMul_SignedSaturatedAdd8(u8 left, u8 right)
-{
+u8 ARMul_SignedSaturatedAdd8(u8 left, u8 right) {
u8 result = left + right;
if (((result ^ left) & 0x80) && ((left ^ right) & 0x80) == 0) {
@@ -86,8 +78,7 @@ u8 ARMul_SignedSaturatedAdd8(u8 left, u8 right)
}
// 8-bit signed saturated subtraction
-u8 ARMul_SignedSaturatedSub8(u8 left, u8 right)
-{
+u8 ARMul_SignedSaturatedSub8(u8 left, u8 right) {
u8 result = left - right;
if (((result ^ left) & 0x80) && ((left ^ right) & 0x80) != 0) {
@@ -101,8 +92,7 @@ u8 ARMul_SignedSaturatedSub8(u8 left, u8 right)
}
// 16-bit signed saturated addition
-u16 ARMul_SignedSaturatedAdd16(u16 left, u16 right)
-{
+u16 ARMul_SignedSaturatedAdd16(u16 left, u16 right) {
u16 result = left + right;
if (((result ^ left) & 0x8000) && ((left ^ right) & 0x8000) == 0) {
@@ -116,8 +106,7 @@ u16 ARMul_SignedSaturatedAdd16(u16 left, u16 right)
}
// 16-bit signed saturated subtraction
-u16 ARMul_SignedSaturatedSub16(u16 left, u16 right)
-{
+u16 ARMul_SignedSaturatedSub16(u16 left, u16 right) {
u16 result = left - right;
if (((result ^ left) & 0x8000) && ((left ^ right) & 0x8000) != 0) {
@@ -131,8 +120,7 @@ u16 ARMul_SignedSaturatedSub16(u16 left, u16 right)
}
// 8-bit unsigned saturated addition
-u8 ARMul_UnsignedSaturatedAdd8(u8 left, u8 right)
-{
+u8 ARMul_UnsignedSaturatedAdd8(u8 left, u8 right) {
u8 result = left + right;
if (result < left)
@@ -142,8 +130,7 @@ u8 ARMul_UnsignedSaturatedAdd8(u8 left, u8 right)
}
// 16-bit unsigned saturated addition
-u16 ARMul_UnsignedSaturatedAdd16(u16 left, u16 right)
-{
+u16 ARMul_UnsignedSaturatedAdd16(u16 left, u16 right) {
u16 result = left + right;
if (result < left)
@@ -153,8 +140,7 @@ u16 ARMul_UnsignedSaturatedAdd16(u16 left, u16 right)
}
// 8-bit unsigned saturated subtraction
-u8 ARMul_UnsignedSaturatedSub8(u8 left, u8 right)
-{
+u8 ARMul_UnsignedSaturatedSub8(u8 left, u8 right) {
if (left <= right)
return 0;
@@ -162,8 +148,7 @@ u8 ARMul_UnsignedSaturatedSub8(u8 left, u8 right)
}
// 16-bit unsigned saturated subtraction
-u16 ARMul_UnsignedSaturatedSub16(u16 left, u16 right)
-{
+u16 ARMul_UnsignedSaturatedSub16(u16 left, u16 right) {
if (left <= right)
return 0;
@@ -171,16 +156,14 @@ u16 ARMul_UnsignedSaturatedSub16(u16 left, u16 right)
}
// Signed saturation.
-u32 ARMul_SignedSatQ(s32 value, u8 shift, bool* saturation_occurred)
-{
+u32 ARMul_SignedSatQ(s32 value, u8 shift, bool* saturation_occurred) {
const u32 max = (1 << shift) - 1;
const s32 top = (value >> shift);
if (top > 0) {
*saturation_occurred = true;
return max;
- }
- else if (top < -1) {
+ } else if (top < -1) {
*saturation_occurred = true;
return ~max;
}
@@ -190,8 +173,7 @@ u32 ARMul_SignedSatQ(s32 value, u8 shift, bool* saturation_occurred)
}
// Unsigned saturation
-u32 ARMul_UnsignedSatQ(s32 value, u8 shift, bool* saturation_occurred)
-{
+u32 ARMul_UnsignedSatQ(s32 value, u8 shift, bool* saturation_occurred) {
const u32 max = (1 << shift) - 1;
if (value < 0) {