amdgpu/dc: use the builtin constant p trick on the 31/32 fixed point.

This only gets us 100 bytes, but may as well be consistent.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Dave Airlie
2017-09-29 17:13:26 +10:00
committed by Alex Deucher
parent dfd1e5ce67
commit c233e91b0f
2 changed files with 23 additions and 14 deletions

View File

@@ -28,6 +28,8 @@
#include "os_types.h"
#define FIXED31_32_BITS_PER_FRACTIONAL_PART 32
/*
* @brief
* Arithmetic operations on real numbers
@@ -78,8 +80,17 @@ struct fixed31_32 dal_fixed31_32_from_fraction(
* @brief
* result = arg
*/
struct fixed31_32 dal_fixed31_32_from_int(
int64_t arg);
struct fixed31_32 dal_fixed31_32_from_int_nonconst(int64_t arg);
static inline struct fixed31_32 dal_fixed31_32_from_int(int64_t arg)
{
if (__builtin_constant_p(arg)) {
struct fixed31_32 res;
BUILD_BUG_ON((LONG_MIN > arg) || (arg > LONG_MAX));
res.value = arg << FIXED31_32_BITS_PER_FRACTIONAL_PART;
return res;
} else
return dal_fixed31_32_from_int_nonconst(arg);
}
/*
* @brief