tipc
A TIP to LLVM compiler
CubicSolver.h
Go to the documentation of this file.
1 #include "ASTFunction.h"
2 #include "ASTNode.h"
3 #include <map>
4 #include <set>
5 #include <utility>
6 #include <vector>
7 
8 class CubicSolver;
9 
11 public:
12  CubicSolverNode(int count);
13 
14 private:
15  friend CubicSolver;
16  std::set<std::shared_ptr<CubicSolverNode>> supsets;
17  std::set<std::shared_ptr<CubicSolverNode>> subsets;
18  std::vector<bool> bitvector;
19  int size;
20  std::vector<std::vector<std::pair<ASTNode *, ASTNode *>>>
21  conditionalConstraints;
22 };
23 
24 class CubicSolver {
25 public:
26  CubicSolver(std::vector<ASTFunction *> functions);
28  void addConditionalConstraint(ASTFunction *condition, ASTNode *in,
29  ASTNode *from, ASTNode *to);
30  void addSubseteqConstraint(ASTNode *from, ASTNode *to);
31  std::vector<ASTFunction *> getPossibleFunctionsForExpr(ASTNode *);
32 
33 private:
34  void activateConditionalConstraint(ASTNode *from, ASTNode *to);
35  void addEmptyVariableIfNecessary(ASTNode *node);
36  std::shared_ptr<CubicSolverNode>
37  killCyclesAt(std::shared_ptr<CubicSolverNode> n);
38  std::vector<std::shared_ptr<CubicSolverNode>>
39  findPath(std::shared_ptr<CubicSolverNode> source,
40  std::shared_ptr<CubicSolverNode> target);
41  std::shared_ptr<CubicSolverNode>
42  mergePath(std::vector<std::shared_ptr<CubicSolverNode>> &path);
43  std::shared_ptr<CubicSolverNode>
44  mergeNodes(std::shared_ptr<CubicSolverNode> n1,
45  std::shared_ptr<CubicSolverNode> n2);
46  void propagateNodeChanges(std::shared_ptr<CubicSolverNode> node);
47  std::map<ASTFunction *, int> fmapping;
48  std::map<ASTNode *, std::shared_ptr<CubicSolverNode>> dagmapping;
49 };
Class for defining the signature, local declarations, and a body of a function.
Definition: ASTFunction.h:11
Abstract base class for all AST nodes.
Definition: ASTNode.h:34
Definition: CubicSolver.h:10
CubicSolverNode(int count)
Definition: CubicSolver.cpp:6
Definition: CubicSolver.h:24
CubicSolver(std::vector< ASTFunction * > functions)
Definition: CubicSolver.cpp:15
void addElementofConstraint(ASTFunction *fn, ASTNode *node)
Definition: CubicSolver.cpp:28
void addSubseteqConstraint(ASTNode *from, ASTNode *to)
Definition: CubicSolver.cpp:49
std::vector< ASTFunction * > getPossibleFunctionsForExpr(ASTNode *)
Definition: CubicSolver.cpp:217
void addConditionalConstraint(ASTFunction *condition, ASTNode *in, ASTNode *from, ASTNode *to)
Definition: CubicSolver.cpp:36