a6bf955d8c64a5635651c565fb9b604775183f42
[satune.git] / src / Translator / decomposeorderresolver.h
1
2 /*
3  * File:   DecomposeOrderResolver.h
4  * Author: hamed
5  *
6  * Created on September 1, 2017, 10:36 AM
7  */
8
9 #ifndef DECOMPOSEORDERRESOLVER_H
10 #define DECOMPOSEORDERRESOLVER_H
11 #include "classlist.h"
12 #include "mymemory.h"
13 #include "structs.h"
14 #include "orderresolver.h"
15
16 class DOREdge {
17  public:
18  DOREdge(uint64_t _origfirst, uint64_t _origsecond, uint _orderindex, uint64_t _newfirst, uint64_t _newsecond) :
19           origfirst(_origfirst),
20                 origsecond(_origsecond),
21                 orderindex(_orderindex),
22                 newfirst(_newfirst),
23                 newsecond(_newsecond) {
24         }               
25         uint64_t origfirst;
26         uint64_t origsecond;
27         uint orderindex;
28         uint64_t newfirst;
29         uint64_t newsecond;
30         CMEMALLOC;
31 };
32
33 class DecomposeOrderResolver : public OrderResolver {
34 public:
35         DecomposeOrderResolver(Order *_order);
36         virtual bool resolveOrder(uint64_t first, uint64_t second);
37         virtual ~DecomposeOrderResolver();
38         void mustOrderEdge(uint64_t first, uint64_t second);
39         void remapEdge(uint64_t oldfirst, uint64_t oldsecond, uint64_t newfirst, uint64_t newsecond);
40         void setEdgeOrder(uint64_t first, uint64_t second, uint sccNum);
41         void setOrder(uint sccNum, Order *order);
42         Order * getOrder(uint sccNum);
43         CMEMALLOC;
44         
45  private:
46         bool resolvePartialOrder(OrderNode *first, OrderNode *second);
47         void buildGraph();
48         OrderGraph *graph;
49         Order *order;
50         Vector<Order *> orders;
51         HashsetDOREdge edges;
52 };
53
54 #endif/* DECOMPOSEORDERRESOLVER_H */
55