summaryrefslogtreecommitdiff
path: root/compiler_and_linker/FrontEnd/Optimizer/BitVector.h
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-01-26 11:30:47 +0000
committerAsh Wolf <ninji@wuffs.org>2023-01-26 11:30:47 +0000
commit094b96ca1df4a035b5f93c351f773306c0241f3f (patch)
tree95ce05e3ebe816c7ee7996206bb37ea17d8ca33c /compiler_and_linker/FrontEnd/Optimizer/BitVector.h
parentfc0c4c0df7b583b55a08317cf1ef6a71d27c0440 (diff)
downloadMWCC-094b96ca1df4a035b5f93c351f773306c0241f3f.tar.gz
MWCC-094b96ca1df4a035b5f93c351f773306c0241f3f.zip
move lots of source files around to match their actual placement in the original treemain
Diffstat (limited to 'compiler_and_linker/FrontEnd/Optimizer/BitVector.h')
-rw-r--r--compiler_and_linker/FrontEnd/Optimizer/BitVector.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/compiler_and_linker/FrontEnd/Optimizer/BitVector.h b/compiler_and_linker/FrontEnd/Optimizer/BitVector.h
new file mode 100644
index 0000000..a6830d6
--- /dev/null
+++ b/compiler_and_linker/FrontEnd/Optimizer/BitVector.h
@@ -0,0 +1,36 @@
+#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);
+
+CW_INLINE void Bv_SetBit(UInt32 bit, BitVector *bv) {
+ if ((bit / 32) < bv->size) {
+ bv->data[bit / 32] |= 1 << (bit & 31);
+ } else {
+ CError_FATAL(56);
+ }
+}
+
+#define Bv_IsBitSet(_bit, _bv) ( (((_bit) >> 5) < (_bv)->size) && ((_bv)->data[(_bit) >> 5] & (1 << ((_bit) & 31))) )
+
+#endif