From 63c05c071785b09435de85b025efd59bb8a3ea56 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sat, 7 Mar 2020 20:10:46 -0800 Subject: [PATCH] base: Clean up condcodes.hh slightly. Correct some minor style issues, make the functions static, and use the single bit version of bits. Change-Id: I4708961745a33caabecfbb06f8113ce8980e399e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26424 Reviewed-by: Gabe Black Reviewed-by: Daniel Carvalho Maintainer: Gabe Black Tested-by: kokoro --- src/base/condcodes.hh | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/base/condcodes.hh b/src/base/condcodes.hh index 2980a1478..5de2daa77 100644 --- a/src/base/condcodes.hh +++ b/src/base/condcodes.hh @@ -30,7 +30,6 @@ #define __BASE_CONDCODE_HH__ #include "base/bitfield.hh" -#include "base/trace.hh" /** * Calculate the carry flag from an addition. This should work even when @@ -76,9 +75,9 @@ * src1 and src2 can neither be 1. So the overall result bit is 1. Hence: * ~1 + 0 + 0 => 0. We return false. */ -inline -bool -findCarry(int width, uint64_t dest, uint64_t src1, uint64_t src2) { +static inline bool +findCarry(int width, uint64_t dest, uint64_t src1, uint64_t src2) +{ int shift = width - 1; return ((~(dest >> shift) & 1) + ((src1 >> shift) & 1) + @@ -88,9 +87,9 @@ findCarry(int width, uint64_t dest, uint64_t src1, uint64_t src2) { /** * Calculate the overflow flag from an addition. */ -inline -bool -findOverflow(int width, uint64_t dest, uint64_t src1, uint64_t src2) { +static inline bool +findOverflow(int width, uint64_t dest, uint64_t src1, uint64_t src2) +{ int shift = width - 1; return ((src1 ^ ~src2) & (src1 ^ dest)) & (1ULL << shift); } @@ -111,9 +110,9 @@ findOverflow(int width, uint64_t dest, uint64_t src1, uint64_t src2) { * which does not have a corresponding high bit. Therefore, the value must * have odd parity, and we return 1 accordingly. Otherwise we return 0. */ -inline -bool -findParity(int width, uint64_t dest) { +static inline bool +findParity(int width, uint64_t dest) +{ dest &= mask(width); dest ^= (dest >> 32); dest ^= (dest >> 16); @@ -127,18 +126,18 @@ findParity(int width, uint64_t dest) { /** * Calculate the negative flag. */ -inline -bool -findNegative(int width, uint64_t dest) { - return bits(dest, width - 1, width - 1); +static inline bool +findNegative(int width, uint64_t dest) +{ + return bits(dest, width - 1); } /** * Calculate the zero flag. */ -inline -bool -findZero(int width, uint64_t dest) { +static inline bool +findZero(int width, uint64_t dest) +{ return !(dest & mask(width)); } -- 2.30.2