commit after resolving conflicts
[satune.git] / src / constraint.h
1 /*      Copyright (c) 2015 Regents of the University of California
2  *
3  *      Author: Brian Demsky <bdemsky@uci.edu>
4  *
5  *      This program is free software; you can redistribute it and/or
6  *      modify it under the terms of the GNU General Public License
7  *      version 2 as published by the Free Software Foundation.
8  */
9
10 #ifndef CONSTRAINT_H
11 #define CONSTRAINT_H
12 #include "classlist.h"
13 #include "structs.h"
14
15 enum ConstraintType {
16         TRUE, FALSE, IMPLIES, AND, OR, VAR, NOTVAR, BOGUS
17 };
18
19 typedef enum ConstraintType CType;
20
21 struct Constraint {
22         CType type;
23         uint numoperandsorvar;
24         Constraint ** operands;
25         Constraint *neg;
26 };
27
28 Constraint * allocConstraint(CType t, Constraint *l, Constraint *r);
29 Constraint * allocUnaryConstraint(CType t, Constraint *l);
30 Constraint * allocArrayConstraint(CType t, uint num, Constraint ** array);
31 Constraint * allocVarConstraint(CType t, uint var);
32
33 void deleteConstraint(Constraint *);
34 void printConstraint(Constraint * c);
35 void dumpConstraint(Constraint * c, IncrementalSolver *solver);
36 uint getVarConstraint(Constraint * c) {ASSERT(c->type==VAR); return c->numoperandsorvar;}
37 VectorConstraint * simplify(Constraint * c);
38 CType getType(Constraint * c) {return c->type;}
39 bool isFalse(Constraint * c) {return c->type==FALSE;}
40 bool isTrue(Constraint * c) {return c->type==TRUE;}
41 void internalfreeConstraint(Constraint * c);
42 void freerecConstraint(Constraint * c);
43 Constraint * cloneConstraint(Constraint * c);
44 void setNegConstraint(Constraint * this, Constraint *c) {this->neg=c;}
45 Constraint *negateConstraint(Constraint * c);
46
47 extern Constraint ctrue;
48 extern Constraint cfalse;
49
50 Constraint * generateConstraint(uint numvars, Constraint ** vars, uint value);
51 Constraint * generateLTConstraint(uint numvars, Constraint ** vars, uint value);
52 Constraint * generateEquivNVConstraint(uint numvars, Constraint **var1, Constraint **var2);
53 Constraint * generateEquivConstraint(Constraint *var1, Constraint *var2);
54 #endif