#define ASTNODE_H
#include "classlist.h"
#include "ops.h"
+#include "astops.h"
class ASTNode {
public:
#include "classlist.h"
#include "mymemory.h"
#include "ops.h"
+#include "astops.h"
#include "structs.h"
#include "astnode.h"
#include "functionencoding.h"
#include "classlist.h"
#include "mymemory.h"
#include "ops.h"
+#include "astops.h"
#include "structs.h"
class Function {
typedef enum HappenedBefore HappenedBefore;
/**
- * FLAGFORCESOVERFLOW forces the operation to overflow if the boolean flag is true
- * OVERFLOWSETSFLAG -- sets the flag if the operation overflows
- * FLAGIFFOVERFLOW -- flag is set iff the operation overflows
+ * SATC_FLAGFORCESOVERFLOW forces the operation to overflow if the boolean flag is true
+ * SATC_OVERFLOWSETSFLAG -- sets the flag if the operation overflows
+ * SATC_FLAGIFFOVERFLOW -- flag is set iff the operation overflows
* SATC_IGNORE -- doesn't constrain output if the result cannot be represented
* SATC_WRAPAROUND -- wraps around like stand integer arithmetic
- * NOOVERFLOW -- client has ensured that overflow is impossible
+ * SATC_NOOVERFLOW -- client has ensured that overflow is impossible
*/
-enum OverFlowBehavior {SATC_IGNORE, SATC_WRAPAROUND, FLAGFORCESOVERFLOW, OVERFLOWSETSFLAG, FLAGIFFOVERFLOW, NOOVERFLOW};
+enum OverFlowBehavior {SATC_IGNORE, SATC_WRAPAROUND, SATC_FLAGFORCESOVERFLOW, SATC_OVERFLOWSETSFLAG, SATC_FLAGIFFOVERFLOW, SATC_NOOVERFLOW};
typedef enum OverFlowBehavior OverFlowBehavior;
-enum UndefinedBehavior {SATC_IGNOREBEHAVIOR, FLAGFORCEUNDEFINED, UNDEFINEDSETSFLAG, FLAGIFFUNDEFINED};
+enum UndefinedBehavior {SATC_IGNOREBEHAVIOR, SATC_FLAGFORCEUNDEFINED, SATC_UNDEFINEDSETSFLAG, SATC_FLAGIFFUNDEFINED};
typedef enum UndefinedBehavior UndefinedBehavior;
-enum FunctionType {TABLEFUNC, OPERATORFUNC};
-typedef enum FunctionType FunctionType;
-
-enum PredicateType {TABLEPRED, OPERATORPRED};
-typedef enum PredicateType PredicateType;
-
-enum ASTNodeType {ORDERCONST, BOOLEANVAR, LOGICOP, PREDICATEOP, BOOLCONST, ELEMSET, ELEMFUNCRETURN, ELEMCONST};
-typedef enum ASTNodeType ASTNodeType;
-
-enum Polarity {P_UNDEFINED=0, P_TRUE=1, P_FALSE=2, P_BOTHTRUEFALSE=3};
-typedef enum Polarity Polarity;
-
-enum BooleanValue {BV_UNDEFINED=0, BV_MUSTBETRUE=1, BV_MUSTBEFALSE=2, BV_UNSAT=3};
-typedef enum BooleanValue BooleanValue;
-
#endif
#include "classlist.h"
#include "mymemory.h"
#include "ops.h"
+#include "astops.h"
#include "structs.h"
#include "common.h"
uint64_t result = function->applyFunctionOperator(numDomains, vals);
bool isInRange = ((FunctionOperator *)func->function)->isInRangeFunction(result);
bool needClause = isInRange;
- if (function->overflowbehavior == OVERFLOWSETSFLAG || function->overflowbehavior == FLAGIFFOVERFLOW) {
+ if (function->overflowbehavior == SATC_OVERFLOWSETSFLAG || function->overflowbehavior == SATC_FLAGIFFOVERFLOW) {
needClause = true;
}
Edge clause;
switch (function->overflowbehavior) {
case SATC_IGNORE:
- case NOOVERFLOW:
+ case SATC_NOOVERFLOW:
case SATC_WRAPAROUND: {
clause = constraintIMPLIES(cnf, constraintAND(cnf, numDomains, carray), carray[numDomains]);
break;
}
- case FLAGFORCESOVERFLOW: {
+ case SATC_FLAGFORCESOVERFLOW: {
clause = constraintIMPLIES(cnf,constraintAND(cnf, numDomains, carray), constraintAND2(cnf, carray[numDomains], constraintNegate(overFlowConstraint)));
break;
}
- case OVERFLOWSETSFLAG: {
+ case SATC_OVERFLOWSETSFLAG: {
if (isInRange) {
clause = constraintIMPLIES(cnf, constraintAND(cnf, numDomains, carray), carray[numDomains]);
} else {
}
break;
}
- case FLAGIFFOVERFLOW: {
+ case SATC_FLAGIFFOVERFLOW: {
if (isInRange) {
clause = constraintIMPLIES(cnf, constraintAND(cnf, numDomains, carray), constraintAND2(cnf, carray[numDomains], constraintNegate(overFlowConstraint)));
} else {
Edge SATEncoder::encodeEnumEntriesTablePredicateSATEncoder(BooleanPredicate *constraint) {
ASSERT(constraint->predicate->type == TABLEPRED);
UndefinedBehavior undefStatus = ((PredicateTable *)constraint->predicate)->undefinedbehavior;
- ASSERT(undefStatus == SATC_IGNOREBEHAVIOR || undefStatus == FLAGFORCEUNDEFINED);
+ ASSERT(undefStatus == SATC_IGNOREBEHAVIOR || undefStatus == SATC_FLAGFORCEUNDEFINED);
Table *table = ((PredicateTable *)constraint->predicate)->table;
FunctionEncodingType encType = constraint->encoding.type;
Array<Element *> *inputs = &constraint->inputs;
case SATC_IGNOREBEHAVIOR:
row = constraintAND(cnf, inputNum, carray);
break;
- case FLAGFORCEUNDEFINED: {
+ case SATC_FLAGFORCEUNDEFINED: {
addConstraintCNF(cnf, constraintIMPLIES(cnf, constraintAND(cnf, inputNum, carray), constraintNegate(undefConst)));
if (generateNegation == (entry->output != 0)) {
continue;
PredicateTable *predicate = (PredicateTable *)constraint->predicate;
switch (predicate->undefinedbehavior) {
case SATC_IGNOREBEHAVIOR:
- case FLAGFORCEUNDEFINED:
+ case SATC_FLAGFORCEUNDEFINED:
return encodeEnumEntriesTablePredicateSATEncoder(constraint);
default:
break;
}
switch (predicate->undefinedbehavior) {
- case UNDEFINEDSETSFLAG:
+ case SATC_UNDEFINEDSETSFLAG:
if (isInRange) {
clause = constraintAND(cnf, numDomains, carray);
} else {
addConstraintCNF(cnf, constraintIMPLIES(cnf,constraintAND(cnf, numDomains, carray), undefConstraint) );
}
break;
- case FLAGIFFUNDEFINED:
+ case SATC_FLAGIFFUNDEFINED:
if (isInRange) {
clause = constraintAND(cnf, numDomains, carray);
addConstraintCNF(cnf, constraintIMPLIES(cnf, constraintAND(cnf, numDomains, carray), constraintNegate(undefConstraint)));
void SATEncoder::encodeEnumEntriesTableElemFuncSATEncoder(ElementFunction *func) {
UndefinedBehavior undefStatus = ((FunctionTable *) func->function)->undefBehavior;
- ASSERT(undefStatus == SATC_IGNOREBEHAVIOR || undefStatus == FLAGFORCEUNDEFINED);
+ ASSERT(undefStatus == SATC_IGNOREBEHAVIOR || undefStatus == SATC_FLAGFORCEUNDEFINED);
Array<Element *> *elements = &func->inputs;
Table *table = ((FunctionTable *) (func->function))->table;
uint size = table->entries->getSize();
row = constraintIMPLIES(cnf,constraintAND(cnf, inputNum, carray), output);
break;
}
- case FLAGFORCEUNDEFINED: {
+ case SATC_FLAGFORCEUNDEFINED: {
Edge undefConst = encodeConstraintSATEncoder(func->overflowstatus);
row = constraintIMPLIES(cnf, constraintAND(cnf, inputNum, carray), constraintAND2(cnf, output, constraintNegate(undefConst)));
break;
FunctionTable *function = (FunctionTable *)elemFunc->function;
switch (function->undefBehavior) {
case SATC_IGNOREBEHAVIOR:
- case FLAGFORCEUNDEFINED:
+ case SATC_FLAGFORCEUNDEFINED:
return encodeEnumEntriesTableElemFuncSATEncoder(elemFunc);
default:
break;
Edge carray[numDomains + 1];
TableEntry *tableEntry = function->table->getTableEntry(vals, numDomains);
bool isInRange = tableEntry != NULL;
- ASSERT(function->undefBehavior == UNDEFINEDSETSFLAG || function->undefBehavior == FLAGIFFUNDEFINED);
+ ASSERT(function->undefBehavior == SATC_UNDEFINEDSETSFLAG || function->undefBehavior == SATC_FLAGIFFUNDEFINED);
for (uint i = 0; i < numDomains; i++) {
Element *elem = elemFunc->inputs.get(i);
carray[i] = getElementValueConstraint(elem, vals[i]);
Edge clause;
switch (function->undefBehavior) {
- case UNDEFINEDSETSFLAG: {
+ case SATC_UNDEFINEDSETSFLAG: {
if (isInRange) {
//FIXME: Talk to Brian, It should be IFF not only IMPLY. --HG
clause = constraintIMPLIES(cnf, constraintAND(cnf, numDomains, carray), carray[numDomains]);
}
break;
}
- case FLAGIFFUNDEFINED: {
+ case SATC_FLAGIFFUNDEFINED: {
if (isInRange) {
clause = constraintIMPLIES(cnf, constraintAND(cnf, numDomains, carray), carray[numDomains]);
addConstraintCNF(cnf, constraintIMPLIES(cnf, constraintAND(cnf, numDomains, carray), constraintNegate(undefConstraint) ));
solver->addTableEntry(t1, row4, 2, 5);
solver->addTableEntry(t1, row5, 2, 3);
solver->addTableEntry(t1, row6, 2, 5);
- Function *f1 = solver->completeTable(t1, FLAGIFFUNDEFINED);
+ Function *f1 = solver->completeTable(t1, SATC_FLAGIFFUNDEFINED);
Element *tmparray[] = {e1, e2};
Element *e3 = solver->applyFunction(f1, tmparray, 2, overflow);
solver->addTableEntry(t1, row4, 3, false);
solver->addTableEntry(t1, row5, 3, false);
solver->addTableEntry(t1, row6, 3, true);
- Predicate *p1 = solver->createPredicateTable(t1, FLAGIFFUNDEFINED);
+ Predicate *p1 = solver->createPredicateTable(t1, SATC_FLAGIFFUNDEFINED);
Boolean *undef = solver->getBooleanVar(2);
Element *tmparray[] = {e1, e2, e3};
Boolean *b1 = solver->applyPredicateTable(p1, tmparray, 3, undef);
#include "polarityassignment.h"
#include "analyzer.h"
#include "autotuner.h"
+#include "astops.h"
CSolver::CSolver() :
boolTrue(new BooleanConst(true)),