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:
parent
35877cd7b8
commit
ea42a3bee5
|
@ -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}_ */
|
||||
|
||||
"""
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue