mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
i965: Use compiler builtins when available
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
8ea6e98c7b
commit
41260a9bf6
4 changed files with 25 additions and 20 deletions
|
|
@ -37,16 +37,6 @@
|
|||
#include "brw_util.h"
|
||||
#include "brw_defines.h"
|
||||
|
||||
GLuint brw_count_bits(uint64_t val)
|
||||
{
|
||||
GLuint i;
|
||||
for (i = 0; val ; val >>= 1)
|
||||
if (val & 1)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
GLuint brw_translate_blend_equation( GLenum mode )
|
||||
{
|
||||
switch (mode) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,14 @@
|
|||
|
||||
#include "main/mtypes.h"
|
||||
|
||||
extern GLuint brw_count_bits(uint64_t val);
|
||||
#ifdef __GNUC__
|
||||
#define brw_count_bits(v) __builtin_popcount(v)
|
||||
#else
|
||||
static inline GLuint brw_count_bits(uint64_t v)
|
||||
{
|
||||
return _mesa_popcount(v>>32) + _mesa_popcount(v&0xffffffff);
|
||||
}
|
||||
#endif
|
||||
extern GLuint brw_parameter_list_state_flags(struct gl_program_parameter_list *paramList);
|
||||
extern GLuint brw_translate_blend_factor( GLenum factor );
|
||||
extern GLuint brw_translate_blend_equation( GLenum mode );
|
||||
|
|
|
|||
|
|
@ -453,6 +453,7 @@ _mesa_inv_sqrtf(float n)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
/**
|
||||
* Find the first bit set in a word.
|
||||
*/
|
||||
|
|
@ -496,9 +497,6 @@ _mesa_ffs(int32_t i)
|
|||
int
|
||||
_mesa_ffsll(int64_t val)
|
||||
{
|
||||
#ifdef ffsll
|
||||
return ffsll(val);
|
||||
#else
|
||||
int bit;
|
||||
|
||||
assert(sizeof(val) == 8);
|
||||
|
|
@ -512,27 +510,24 @@ _mesa_ffsll(int64_t val)
|
|||
return 32 + bit;
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if ((_GNUC__ == 3 && __GNUC_MINOR__ < 4) || __GNUC__ < 4)
|
||||
/**
|
||||
* Return number of bits set in given GLuint.
|
||||
*/
|
||||
unsigned int
|
||||
_mesa_bitcount(unsigned int n)
|
||||
{
|
||||
#if defined(__GNUC__) && \
|
||||
((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
|
||||
return __builtin_popcount(n);
|
||||
#else
|
||||
unsigned int bits;
|
||||
for (bits = 0; n > 0; n = n >> 1) {
|
||||
bits += (n & 1);
|
||||
}
|
||||
return bits;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -539,6 +539,18 @@ _mesa_inv_sqrtf(float x);
|
|||
extern void
|
||||
_mesa_init_sqrt_table(void);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _mesa_ffs(i) ffs(i)
|
||||
#define _mesa_ffsll(i) ffsll(i)
|
||||
|
||||
#if ((_GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
|
||||
#define _mesa_bitcount(i) __builtin_popcount(i)
|
||||
#else
|
||||
extern unsigned int
|
||||
_mesa_bitcount(unsigned int n);
|
||||
#endif
|
||||
|
||||
#else
|
||||
extern int
|
||||
_mesa_ffs(int32_t i);
|
||||
|
||||
|
|
@ -547,6 +559,7 @@ _mesa_ffsll(int64_t i);
|
|||
|
||||
extern unsigned int
|
||||
_mesa_bitcount(unsigned int n);
|
||||
#endif
|
||||
|
||||
extern GLhalfARB
|
||||
_mesa_float_to_half(float f);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue