- extend mulscale/divscale pragmas with double versions of each.

This commit is contained in:
Mitchell Richters 2020-08-02 22:28:17 +10:00 committed by Christoph Oelckers
parent 9c8593018b
commit 3d165ee182

View file

@ -19,7 +19,7 @@
EDUKE32_SCALER_PRAGMA(17) EDUKE32_SCALER_PRAGMA(18) EDUKE32_SCALER_PRAGMA(19) EDUKE32_SCALER_PRAGMA(20) \
EDUKE32_SCALER_PRAGMA(21) EDUKE32_SCALER_PRAGMA(22) EDUKE32_SCALER_PRAGMA(23) EDUKE32_SCALER_PRAGMA(24) \
EDUKE32_SCALER_PRAGMA(25) EDUKE32_SCALER_PRAGMA(26) EDUKE32_SCALER_PRAGMA(27) EDUKE32_SCALER_PRAGMA(28) \
EDUKE32_SCALER_PRAGMA(29) EDUKE32_SCALER_PRAGMA(30) EDUKE32_SCALER_PRAGMA(31)
EDUKE32_SCALER_PRAGMA(29) EDUKE32_SCALER_PRAGMA(30) EDUKE32_SCALER_PRAGMA(31) EDUKE32_SCALER_PRAGMA(32)
extern int32_t reciptable[2048];
@ -34,12 +34,14 @@ extern int32_t reciptable[2048];
#define DIVTABLESIZE 16384
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return (int64_t(eax) << ecx) / ebx; }
static inline double fdivscale(double eax, double ebx, int32_t ecx) { return (eax * (double)(qw(1) << ecx)) / ebx; }
static inline int64_t divscale64(int64_t eax, int64_t ebx, int64_t ecx) { return (eax << ecx) / ebx; }
#define EDUKE32_SCALER_PRAGMA(a) \
static FORCE_INLINE int32_t divscale##a(int32_t eax, int32_t ebx) { return divscale(eax, ebx, a); }
EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32)
static FORCE_INLINE int32_t divscale##a(int32_t eax, int32_t ebx) { return divscale(eax, ebx, a); } \
static FORCE_INLINE double fdivscale##a(double eax, double ebx) { return fdivscale(eax, ebx, a); }
EDUKE32_GENERATE_PRAGMAS
#undef EDUKE32_SCALER_PRAGMA
static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
@ -54,16 +56,25 @@ static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
#define EDUKE32_SCALER_PRAGMA(a) \
static FORCE_INLINE CONSTEXPR int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * edx) >> by(a)); } \
static FORCE_INLINE CONSTEXPR double fmulscale##a(double eax, double edx) { return (eax * edx) / (double)(qw(1) << a); } \
static FORCE_INLINE CONSTEXPR int32_t dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \
{ \
return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(a)); \
} \
static FORCE_INLINE CONSTEXPR double fdmulscale##a(double eax, double edx, double esi, double edi) \
{ \
return ((eax * edx) + (esi * edi)) / (double)(qw(1) << a); \
} \
static FORCE_INLINE CONSTEXPR int32_t tmulscale##a(int32_t eax, int32_t edx, int32_t ebx, int32_t ecx, int32_t esi, int32_t edi) \
{ \
return dw(((qw(eax) * edx) + (qw(ebx) * ecx) + (qw(esi) * edi)) >> by(a)); \
} \
static FORCE_INLINE CONSTEXPR double ftmulscale##a(double eax, double edx, double ebx, double ecx, double esi, double edi) \
{ \
return ((eax * edx) + (ebx * ecx) + (esi * edi)) / (double)(qw(1) << a); \
}
EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32)
EDUKE32_GENERATE_PRAGMAS
#undef EDUKE32_SCALER_PRAGMA
@ -97,10 +108,15 @@ static FORCE_INLINE CONSTEXPR int ksgn(int32_t a) { return (a > 0) - (a < 0); }
inline int sgn(int32_t a) { return (a > 0) - (a < 0); }
static FORCE_INLINE CONSTEXPR int32_t mulscale(int32_t eax, int32_t edx, int32_t ecx) { return dw((qw(eax) * edx) >> by(ecx)); }
static FORCE_INLINE CONSTEXPR double fmulscale(double eax, double edx, int32_t ecx) { return (eax * edx) / (double)(qw(1) << ecx); }
static FORCE_INLINE CONSTEXPR int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx)
{
return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(ecx));
}
static FORCE_INLINE CONSTEXPR double fdmulscale(double eax, double edx, double esi, double edi, int32_t ecx)
{
return ((eax * edx) + (esi * edi)) / (double)(qw(1) << ecx);
}
static inline int32_t krecipasm(int32_t i)
{