Merge branch 'master' of ssh://demsky.eecs.uci.edu/home/git/constraint_compiler into...
[satune.git] / src / Encoders / elementencoding.h
1 #ifndef ELEMENTENCODING_H
2 #define ELEMENTENCODING_H
3 #include "classlist.h"
4 #include "naiveencoder.h"
5 #include "constraint.h"
6
7 enum ElementEncodingType {
8         ELEM_UNASSIGNED, ONEHOT, UNARY, BINARYINDEX, ONEHOTBINARY, BINARYVAL
9 };
10
11 typedef enum ElementEncodingType ElementEncodingType;
12
13 struct ElementEncoding {
14         ElementEncodingType type;
15         Element * element;
16         Edge * variables;/* List Variables Used To Encode Element */
17         uint64_t * encodingArray;       /* List the Variables in the appropriate order */
18         uint64_t * inUseArray;/* Bitmap to track variables in use */
19         uint encArraySize;
20         uint numVars;   /* Number of variables */
21 };
22
23 void initElementEncoding(ElementEncoding *This, Element *element);
24 static inline ElementEncodingType getElementEncodingType(ElementEncoding * This) {return This->type;}
25 void setElementEncodingType(ElementEncoding* This, ElementEncodingType type);
26 void deleteElementEncoding(ElementEncoding *This);
27 void allocEncodingArrayElement(ElementEncoding *This, uint size);
28 void allocInUseArrayElement(ElementEncoding *This, uint size);
29 void generateBinaryIndexEncodingVars(SATEncoder* encode, ElementEncoding* This);
30 void generateElementEncodingVariables(SATEncoder* encoder, ElementEncoding* This);
31
32 static inline bool isinUseElement(ElementEncoding *This, uint offset) {
33         return (This->inUseArray[(offset>>6)] >> (offset & 63)) &0x1;
34 }
35
36 static inline void setInUseElement(ElementEncoding *This, uint offset) {
37         This->inUseArray[(offset>>6)] |= 1 << (offset & 63);
38 }
39
40 #endif