From 1cab7b97657b080a6849f4be1ead6aee284f442a Mon Sep 17 00:00:00 2001 From: "Richard C. Gobeille" Date: Wed, 10 Jun 2020 08:07:27 -0700 Subject: [PATCH] engine: add divideu64()/divideu64_noinline() --- source/build/include/pragmas.h | 14 ++++++++++++++ source/build/src/pragmas.cpp | 1 + 2 files changed, 15 insertions(+) diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 1c320b7f8..0a32a13dd 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -49,6 +49,19 @@ skip: return libdivide::libdivide_u32_do(n, &udiv); } +static inline uint64_t divideu64(uint64_t const n, uint64_t const d) +{ + static libdivide::libdivide_u64_t udiv; + static uint64_t lastd; + + if (d == lastd) + goto skip; + + udiv = libdivide::libdivide_u64_gen((lastd = d)); +skip: + return libdivide::libdivide_u64_do(n, &udiv); +} + static inline int64_t tabledivide64(int64_t const n, int64_t const d) { static libdivide::libdivide_s64_t sdiv; @@ -78,6 +91,7 @@ skip: } extern uint32_t divideu32_noinline(uint32_t n, uint32_t d); +extern uint64_t divideu64_noinline(uint64_t n, uint64_t d); extern int32_t tabledivide32_noinline(int32_t n, int32_t d); diff --git a/source/build/src/pragmas.cpp b/source/build/src/pragmas.cpp index 97608f66d..9685796a0 100644 --- a/source/build/src/pragmas.cpp +++ b/source/build/src/pragmas.cpp @@ -23,4 +23,5 @@ void initdivtables(void) } uint32_t divideu32_noinline(uint32_t n, uint32_t d) { return divideu32(n, d); } +uint64_t divideu64_noinline(uint64_t n, uint64_t d) { return divideu64(n, d); } int32_t tabledivide32_noinline(int32_t n, int32_t d) { return tabledivide32(n, d); }