Update libdivide from git

git-svn-id: https://svn.eduke32.com/eduke32@7715 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-06-25 11:29:50 +00:00 committed by Christoph Oelckers
parent 4a09e2a183
commit db7a2bd0db
4 changed files with 1135 additions and 1141 deletions

File diff suppressed because it is too large Load diff

View file

@ -41,49 +41,49 @@ extern int32_t reciptable[2048], fpuasm;
#define DIVTABLESIZE 16384 #define DIVTABLESIZE 16384
extern libdivide_s64_t divtable64[DIVTABLESIZE]; extern libdivide::libdivide_s64_t divtable64[DIVTABLESIZE];
extern libdivide_s32_t divtable32[DIVTABLESIZE]; extern libdivide::libdivide_s32_t divtable32[DIVTABLESIZE];
extern void initdivtables(void); extern void initdivtables(void);
static inline uint32_t divideu32(uint32_t const n, uint32_t const d) static inline uint32_t divideu32(uint32_t const n, uint32_t const d)
{ {
static libdivide_u32_t udiv; static libdivide::libdivide_u32_t udiv;
static uint32_t lastd; static uint32_t lastd;
if (d == lastd) if (d == lastd)
goto skip; goto skip;
udiv = libdivide_u32_gen((lastd = d)); udiv = libdivide::libdivide_u32_gen((lastd = d));
skip: skip:
return libdivide_u32_do(n, &udiv); return libdivide::libdivide_u32_do(n, &udiv);
} }
static inline int64_t tabledivide64(int64_t const n, int32_t const d) static inline int64_t tabledivide64(int64_t const n, int32_t const d)
{ {
static libdivide_s64_t sdiv; static libdivide::libdivide_s64_t sdiv;
static int32_t lastd; static int32_t lastd;
auto const dptr = ((unsigned)d < DIVTABLESIZE) ? &divtable64[d] : &sdiv; auto const dptr = ((unsigned)d < DIVTABLESIZE) ? &divtable64[d] : &sdiv;
if (d == lastd || dptr != &sdiv) if (d == lastd || dptr != &sdiv)
goto skip; goto skip;
sdiv = libdivide_s64_gen((lastd = d)); sdiv = libdivide::libdivide_s64_gen((lastd = d));
skip: skip:
return libdivide_s64_do(n, dptr); return libdivide::libdivide_s64_do(n, dptr);
} }
static inline int32_t tabledivide32(int32_t const n, int32_t const d) static inline int32_t tabledivide32(int32_t const n, int32_t const d)
{ {
static libdivide_s32_t sdiv; static libdivide::libdivide_s32_t sdiv;
static int32_t lastd; static int32_t lastd;
auto const dptr = ((unsigned)d < DIVTABLESIZE) ? &divtable32[d] : &sdiv; auto const dptr = ((unsigned)d < DIVTABLESIZE) ? &divtable32[d] : &sdiv;
if (d == lastd || dptr != &sdiv) if (d == lastd || dptr != &sdiv)
goto skip; goto skip;
sdiv = libdivide_s32_gen((lastd = d)); sdiv = libdivide::libdivide_s32_gen((lastd = d));
skip: skip:
return libdivide_s32_do(n, dptr); return libdivide::libdivide_s32_do(n, dptr);
} }
extern uint32_t divideu32_noinline(uint32_t n, uint32_t d); extern uint32_t divideu32_noinline(uint32_t n, uint32_t d);

View file

@ -10,15 +10,15 @@
#include "compat.h" #include "compat.h"
#include "pragmas.h" #include "pragmas.h"
libdivide_s64_t divtable64[DIVTABLESIZE]; libdivide::libdivide_s64_t divtable64[DIVTABLESIZE];
libdivide_s32_t divtable32[DIVTABLESIZE]; libdivide::libdivide_s32_t divtable32[DIVTABLESIZE];
void initdivtables(void) void initdivtables(void)
{ {
for (int i = 1; i < DIVTABLESIZE; ++i) for (int i = 1; i < DIVTABLESIZE; ++i)
{ {
divtable64[i] = libdivide_s64_gen(i); divtable64[i] = libdivide::libdivide_s64_gen(i);
divtable32[i] = libdivide_s32_gen(i); divtable32[i] = libdivide::libdivide_s32_gen(i);
} }
} }

View file

@ -242,15 +242,15 @@ static FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const operan
return; return;
bool const foundInTable = (unsigned) operand < DIVTABLESIZE; bool const foundInTable = (unsigned) operand < DIVTABLESIZE;
static libdivide_s32_t sdiv; static libdivide::libdivide_s32_t sdiv;
intptr_t *iptr = &var.global; intptr_t *iptr = &var.global;
static int32_t lastValue; static int32_t lastValue;
auto dptr = foundInTable ? (libdivide_s32_t *) &divtable32[operand] : &sdiv; auto dptr = foundInTable ? (libdivide::libdivide_s32_t *) &divtable32[operand] : &sdiv;
if (operand == lastValue || foundInTable) if (operand == lastValue || foundInTable)
goto skip; goto skip;
sdiv = libdivide_s32_gen((lastValue = operand)); sdiv = libdivide::libdivide_s32_gen((lastValue = operand));
skip: skip:
switch (var.flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) switch (var.flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
@ -262,13 +262,13 @@ skip:
case GAMEVAR_INT32PTR: case GAMEVAR_INT32PTR:
{ {
int32_t &value = *(int32_t *)var.pValues; int32_t &value = *(int32_t *)var.pValues;
value = (int32_t)libdivide_s32_do(value, dptr); value = (int32_t)libdivide::libdivide_s32_do(value, dptr);
return; return;
} }
case GAMEVAR_INT16PTR: case GAMEVAR_INT16PTR:
{ {
int16_t &value = *(int16_t *)var.pValues; int16_t &value = *(int16_t *)var.pValues;
value = (int16_t)libdivide_s32_do(value, dptr); value = (int16_t)libdivide::libdivide_s32_do(value, dptr);
return; return;
} }
case GAMEVAR_Q16PTR: case GAMEVAR_Q16PTR: