freedreno/isa: add bitmask to/from uint64_t helper

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11321>
This commit is contained in:
Christian Gmeiner 2021-05-16 09:55:59 +02:00 committed by Marge Bot
parent 35877cd7b8
commit ea42a3bee5
2 changed files with 35 additions and 0 deletions

View File

@ -216,6 +216,7 @@ header = """\
#ifndef _${guard}_
#define _${guard}_
#include <stdint.h>
#include <util/bitset.h>
typedef struct {
@ -223,6 +224,23 @@ typedef struct {
} bitmask_t;
static inline uint64_t
bitmask_to_uint64_t(bitmask_t mask)
{
return ((uint64_t)mask.bitset[1] << 32) | mask.bitset[0];
}
static inline bitmask_t
uint64_t_to_bitmask(uint64_t val)
{
bitmask_t mask = {
.bitset[0] = val & 0xffffffff,
.bitset[1] = (val >> 32) & 0xffffffff,
};
return mask;
}
#endif /* _${guard}_ */
"""

View File

@ -339,6 +339,23 @@ typedef struct {
BITSET_WORD bitset[BITSET_WORDS(${isa.bitsize})];
} bitmask_t;
static inline uint64_t
bitmask_to_uint64_t(bitmask_t mask)
{
return ((uint64_t)mask.bitset[1] << 32) | mask.bitset[0];
}
static inline bitmask_t
uint64_t_to_bitmask(uint64_t val)
{
bitmask_t mask = {
.bitset[0] = val & 0xffffffff,
.bitset[1] = (val >> 32) & 0xffffffff,
};
return mask;
}
/**
* Opaque type from the PoV of generated code, but allows state to be passed
* thru to the hand written helpers used by the generated code.