util: Add a helper for faster remainders

This should be at least as fast as using fast_idiv_by_const, and has the
advantage that the precomputation is simple enough to be evaluated at
Mesa-compile time for hash tables and sets which have a fixed table of
possible divisors.

Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
Connor Abbott
2019-03-29 15:08:17 +01:00
parent 983b001c77
commit b87817871b
5 changed files with 210 additions and 0 deletions

View File

@@ -834,6 +834,10 @@ if cc.compiles('int foo(void) __attribute__((__noreturn__));',
name : '__attribute__((__noreturn__))')
pre_args += '-DHAVE_FUNC_ATTRIBUTE_NORETURN'
endif
if cc.compiles('__uint128_t foo(void) { return 0; }',
name : '__uint128_t')
pre_args += '-DHAVE_UINT128'
endif
# TODO: this is very incomplete
if ['linux', 'cygwin', 'gnu'].contains(host_machine.system())