Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/constraint_compiler
[satune.git] / src / AST / function.h
1 #ifndef FUNCTION_H
2 #define FUNCTION_H
3 #include "classlist.h"
4 #include "mymemory.h"
5 #include "ops.h"
6 #include "astops.h"
7 #include "structs.h"
8
9 class Function {
10 public:
11         Function(FunctionType _type) : type(_type) {}
12         FunctionType type;
13         virtual ~Function() {}
14         virtual Function *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;}
15         virtual Set * getRange() = 0;
16         CMEMALLOC;
17 };
18
19 class FunctionOperator : public Function {
20 public:
21         ArithOp op;
22         Array<Set *> domains;
23         Set *range;
24         OverFlowBehavior overflowbehavior;
25         FunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior);
26         uint64_t applyFunctionOperator(uint numVals, uint64_t *values);
27         bool isInRangeFunction(uint64_t val);
28         Function *clone(CSolver *solver, CloneMap *map);
29         Set * getRange() {return range;}
30         CMEMALLOC;
31 };
32
33 class FunctionTable : public Function {
34 public:
35         Table *table;
36         UndefinedBehavior undefBehavior;
37         FunctionTable (Table *table, UndefinedBehavior behavior);
38         Function *clone(CSolver *solver, CloneMap *map);
39         Set * getRange();
40         CMEMALLOC;
41 };
42
43 #endif