2022-11-20 05:07:22 +00:00
|
|
|
#ifndef COMPILER_IROBITVECT_H
|
|
|
|
#define COMPILER_IROBITVECT_H
|
|
|
|
|
|
|
|
#include "compiler/common.h"
|
|
|
|
#include "compiler/CError.h"
|
|
|
|
|
|
|
|
typedef struct BitVector {
|
|
|
|
UInt32 size;
|
|
|
|
UInt32 data[0];
|
|
|
|
} BitVector;
|
|
|
|
|
|
|
|
extern void Bv_AllocVector(BitVector **bv, UInt32 size);
|
|
|
|
extern void Bv_AllocVectorLocal(BitVector **bv, UInt32 size);
|
|
|
|
extern void Bv_ClearBit(UInt32 bit, BitVector *bv);
|
|
|
|
extern void Bv_And(const BitVector *a, BitVector *b);
|
|
|
|
extern void Bv_Or(const BitVector *a, BitVector *b);
|
|
|
|
extern Boolean Bv_BitsInCommon(const BitVector *a, const BitVector *b);
|
|
|
|
extern Boolean Bv_Compare(const BitVector *a, const BitVector *b);
|
|
|
|
extern void Bv_Minus(const BitVector *a, BitVector *b);
|
|
|
|
extern void Bv_Copy(const BitVector *src, BitVector *dst);
|
|
|
|
extern void Bv_Clear(BitVector *bv);
|
|
|
|
extern void Bv_Set(BitVector *bv);
|
|
|
|
extern Boolean Bv_IsSubset(const BitVector *a, const BitVector *b);
|
|
|
|
extern Boolean Bv_IsEmpty(const BitVector *bv);
|
|
|
|
|
2023-01-11 23:26:04 +00:00
|
|
|
CW_INLINE void Bv_SetBit(UInt32 bit, BitVector *bv) {
|
2022-11-20 05:07:22 +00:00
|
|
|
if ((bit / 32) < bv->size) {
|
2022-12-14 00:16:59 +00:00
|
|
|
bv->data[bit / 32] |= 1 << (bit & 31);
|
2022-11-20 05:07:22 +00:00
|
|
|
} else {
|
2022-12-29 12:32:55 +00:00
|
|
|
CError_FATAL(56);
|
2022-11-20 05:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 00:16:59 +00:00
|
|
|
#define Bv_IsBitSet(_bit, _bv) ( (((_bit) >> 5) < (_bv)->size) && ((_bv)->data[(_bit) >> 5] & (1 << ((_bit) & 31))) )
|
|
|
|
|
2022-11-20 05:07:22 +00:00
|
|
|
#endif
|