#ifndef ASTHASH_H
#define ASTHASH_H
-#include "classlist.h"
+#include "classes.h"
#include "hashtable.h"
uint hashBoolean(Boolean * boolean);
public:
ASTNode(ASTNodeType _type) : type(_type) {}
ASTNodeType type;
- MEMALLOC;
+ CMEMALLOC;
};
#endif
BooleanValue boolVal;
Vector<Boolean *> parents;
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanConst : public Boolean {
BooleanConst(bool isTrue);
Boolean *clone(CSolver *solver, CloneMap *map);
bool isTrue;
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanVar : public Boolean {
VarType vtype;
Edge var;
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanOrder : public Boolean {
Order *order;
uint64_t first;
uint64_t second;
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanPredicate : public Boolean {
Array<Element *> inputs;
Boolean *undefStatus;
FunctionEncoding *getFunctionEncoding() {return &encoding;}
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanLogic : public Boolean {
LogicOp op;
Array<Boolean *> inputs;
- MEMALLOC;
+ CMEMALLOC;
};
#endif
ElementEncoding encoding;
virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
- MEMALLOC;
+ CMEMALLOC;
};
class ElementConst : public Element {
Set *set;
uint64_t value;
Element *clone(CSolver *solver, CloneMap *map);
- MEMALLOC;
+ CMEMALLOC;
};
class ElementSet : public Element {
ElementSet(Set *s);
Set *set;
Element *clone(CSolver *solver, CloneMap *map);
- MEMALLOC;
+ CMEMALLOC;
};
class ElementFunction : public Element {
Boolean *overflowstatus;
FunctionEncoding functionencoding;
Element *clone(CSolver *solver, CloneMap *map);
- MEMALLOC;
+ CMEMALLOC;
};
Set *getElementSet(Element *This);
FunctionType type;
virtual ~Function() {}
virtual Function *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;}
- MEMALLOC;
+ CMEMALLOC;
};
class FunctionOperator : public Function {
uint64_t applyFunctionOperator(uint numVals, uint64_t *values);
bool isInRangeFunction(uint64_t val);
Function *clone(CSolver *solver, CloneMap *map);
- MEMALLOC;
+ CMEMALLOC;
};
class FunctionTable : public Function {
UndefinedBehavior undefBehavior;
FunctionTable (Table *table, UndefinedBehavior behavior);
Function *clone(CSolver *solver, CloneMap *map);
- MEMALLOC;
+ CMEMALLOC;
};
#endif
MutableSet(VarType t);
void addElementMSet(uint64_t element);
Set *clone(CSolver *solver, CloneMap *map);
- MEMALLOC;
+ CMEMALLOC;
};
#endif
void initializeOrderElementsHashTable();
void addOrderConstraint(BooleanOrder *constraint);
void setOrderEncodingType(OrderEncodingType type);
- MEMALLOC;
+ CMEMALLOC;
};
#endif
virtual ~Predicate() {}
virtual Predicate *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;}
PredicateType type;
- MEMALLOC;
+ CMEMALLOC;
};
class PredicateOperator : public Predicate {
Predicate *clone(CSolver *solver, CloneMap *map);
CompOp op;
Array<Set *> domains;
- MEMALLOC;
+ CMEMALLOC;
};
class PredicateTable : public Predicate {
Predicate *clone(CSolver *solver, CloneMap *map);
Table *table;
UndefinedBehavior undefinedbehavior;
- MEMALLOC;
+ CMEMALLOC;
};
#endif
uint64_t getMemberAt(uint index);
uint64_t getElement(uint index);
virtual Set *clone(CSolver *solver, CloneMap *map);
- MEMALLOC;
+ CMEMALLOC;
protected:
VarType type;
bool isRange;
Array<Set *> domains;
Set *range;
HashSetTableEntry *entries;
- MEMALLOC;
+ CMEMALLOC;
};
#endif
unsigned int mustPos : 1;
unsigned int mustNeg : 1;
unsigned int pseudoPos : 1;
- MEMALLOC;
+ CMEMALLOC;
};
#endif/* ORDEREDGE_H */
HSIteratorOrderNode *getNodes() {return nodes->iterator();}
HSIteratorOrderEdge *getEdges() {return edges->iterator();}
- MEMALLOC;
+ CMEMALLOC;
private:
HashSetOrderNode *nodes;
HashSetOrderEdge *edges;
uint sccNum;
HashSetOrderEdge inEdges;
HashSetOrderEdge outEdges;
- MEMALLOC;
+ CMEMALLOC;
};
#endif/* ORDERNODE_H */
IntegerEncodingRecord(Set* set);
~IntegerEncodingRecord();
Element* getOrderIntegerElement(CSolver *This, uint64_t item);
- MEMALLOC;
+ CMEMALLOC;
private:
HashSetOrderElement *elementTable;
virtual inline bool canExecutePass(CSolver* This, uint type, Tunables tunable, TunableDesc* desc){
return GETVARTUNABLE(This->getTuner(), type, tunable, desc);
}
- MEMALLOC;
+ CMEMALLOC;
};
OrderElement(uint64_t item, Element *elem);
uint64_t item;
Element *elem;
- MEMALLOC;
+ CMEMALLOC;
};
uint64_t first;
uint64_t second;
Edge constraint;
- MEMALLOC;
+ CMEMALLOC;
};
#endif/* ORDERPAIR_H */
long long getSolveTime() { return cnf->solveTime; }
long long getEncodeTime() { return cnf->encodeTime; }
- MEMALLOC;
+ CMEMALLOC;
private:
Edge getNewVarSATEncoder();
void getArrayNewVarsSATEncoder(uint num, Edge *carray);
--- /dev/null
+#ifndef CORESTRUCTS_H
+#define CORESTRUCTS_H
+
+#include "cppvector.h"
+#include "hashset.h"
+
+typedef HashSet<Boolean *, uintptr_t, 4> HashSetBoolean;
+typedef HSIterator<Boolean *, uintptr_t, 4> HSIteratorBoolean;
+
+#endif
#include "hashset.h"
#include "classlist.h"
#include "array.h"
+#include "corestructs.h"
unsigned int table_entry_hash_function(TableEntry *This);
bool table_entry_equals(TableEntry *key1, TableEntry *key2);
bool order_pair_equals(OrderPair *key1, OrderPair *key2);
-typedef HashSet<Boolean *, uintptr_t, 4> HashSetBoolean;
+
typedef HashSet<TableEntry *, uintptr_t, 4, table_entry_hash_function, table_entry_equals> HashSetTableEntry;
typedef HashSet<OrderNode *, uintptr_t, 4, order_node_hash_function, order_node_equals> HashSetOrderNode;
typedef HashSet<OrderEdge *, uintptr_t, 4, order_edge_hash_function, order_edge_equals> HashSetOrderEdge;
typedef HashTable<Order* , IntegerEncodingRecord*, uintptr_t, 4> HashTableOrderIntegerEncoding;
typedef HSIterator<TableEntry *, uintptr_t, 4, table_entry_hash_function, table_entry_equals> HSIteratorTableEntry;
-typedef HSIterator<Boolean *, uintptr_t, 4> HSIteratorBoolean;
typedef HSIterator<OrderEdge *, uintptr_t, 4, order_edge_hash_function, order_edge_equals> HSIteratorOrderEdge;
typedef HSIterator<OrderNode *, uintptr_t, 4, order_node_hash_function, order_node_equals> HSIteratorOrderNode;
};
};
uint numVars; /* Number of variables */
- MEMALLOC;
+ CMEMALLOC;
};
FunctionEncoding(Boolean *predicate);
void setFunctionEncodingType(FunctionEncodingType type);
FunctionEncodingType getFunctionEncodingType() {return type;}
- MEMALLOC;
+ CMEMALLOC;
};
OrderEncodingType type;
Order *order;
- MEMALLOC;
+ CMEMALLOC;
};
#endif
AutoTuner(uint budget);
void addProblem(CSolver *solver);
void tune();
- MEMALLOC;
+ CMEMALLOC;
private:
long long evaluate(CSolver *problem, SearchTuner *tuner);
double evaluateAll(SearchTuner *tuner);
TunableSetting(TunableSetting * ts);
void setDecision(int _low, int _high, int _default, int _selection);
void print();
- MEMALLOC;
+ CMEMALLOC;
private:
bool hasVar;
VarType type;
void print();
void printUsed();
- MEMALLOC;
+ CMEMALLOC;
private:
/** Used Settings keeps track of settings that were actually used by
the example. Mutating settings may cause the Constraint Compiler
virtual int getTunable(TunableParam param, TunableDesc *descriptor) {ASSERT(0); return 0;}
virtual int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor) {ASSERT(0); return 0;}
virtual ~Tuner() {}
- MEMALLOC;
+ CMEMALLOC;
};
class DefaultTuner : public Tuner {
DefaultTuner();
int getTunable(TunableParam param, TunableDesc *descriptor);
int getVarTunable(VarType vartype, TunableParam param, TunableDesc *descriptor);
- MEMALLOC;
+ CMEMALLOC;
};
int lowValue;
int highValue;
int defaultValue;
- MEMALLOC;
+ CMEMALLOC;
};
--- /dev/null
+/* Copyright (c) 2015 Regents of the University of California
+ *
+ * Author: Brian Demsky <bdemsky@uci.edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#ifndef CLASSES_H
+#define CLASSES_H
+
+#include "mymemory.h"
+#include <inttypes.h>
+
+class SATEncoder;
+class CSolver;
+class Boolean;
+class Element;
+class Predicate;
+class Table;
+class Order;
+class MutableSet;
+class Function;
+class Tuner;
+class Set;
+class BooleanLogic;
+typedef uint64_t VarType;
+
+#endif
#include "mymemory.h"
#include <inttypes.h>
+#include "classes.h"
+
-class CSolver;
-class SATEncoder;
-class Boolean;
class BooleanOrder;
class BooleanVar;
-class BooleanLogic;
+
class BooleanPredicate;
class ASTNode;
-class Set;
-class MutableSet;
+
+
class ElementFunction;
class ElementSet;
class ElementConst;
-class Element;
class FunctionOperator;
class FunctionTable;
-class Function;
-class Predicate;
+
+
class PredicateTable;
class PredicateOperator;
-class Table;
-class Order;
+
+
class OrderPair;
class OrderElement;
class SearchTuner;
class TunableSetting;
+class TunableDesc;
+
struct IncrementalSolver;
typedef struct IncrementalSolver IncrementalSolver;
struct TableEntry;
typedef struct TableEntry TableEntry;
-class Tuner;
-class TunableDesc;
-
typedef int TunableParam;
-
typedef unsigned int uint;
typedef long int int64;
-typedef uint64_t VarType;
+
#endif
#include "analyzer.h"
#include "autotuner.h"
#include "astops.h"
+#include "structs.h"
CSolver::CSolver() :
boolTrue(new BooleanConst(true)),
#ifndef CSOLVER_H
#define CSOLVER_H
-#include "classlist.h"
+#include "classes.h"
#include "ops.h"
-#include "structs.h"
+#include "corestructs.h"
#include "asthash.h"
class CSolver {
long long getEncodeTime();
long long getSolveTime();
- MEMALLOC;
+ CMEMALLOC;
private:
void handleXORFalse(BooleanLogic *bexpr, Boolean *child);
* @brief Memory allocation functions.
*/
-#ifndef _MY_MEMORY_H
-#define _MY_MEMORY_H
+#ifndef CSAT_MY_MEMORY_H
+#define CSAT_MY_MEMORY_H
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
static inline void *ourcalloc(size_t count, size_t size) { return calloc(count, size); }
static inline void *ourrealloc(void *ptr, size_t size) { return realloc(ptr, size); }
-#define MEMALLOC \
+#define CMEMALLOC \
void *operator new(size_t size) { \
return ourmalloc(size); \
} \