/builds/2mk6rsew/0/parcoach/parcoach/src/include/parcoach/andersen/Constraint.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef ANDERSEN_CONSTRAINT_H |
2 | | #define ANDERSEN_CONSTRAINT_H |
3 | | |
4 | | #include "NodeFactory.h" |
5 | | |
6 | | #include <cassert> |
7 | | |
8 | | /// AndersConstraint - Objects of this structure are used to represent the |
9 | | /// various constraints identified by the algorithm. The constraints are |
10 | | /// 'copy', for statements like "A = B", 'load' for statements like "A = *B", |
11 | | /// 'store' for statements like "*A = B", and AddressOf for statements like A = |
12 | | /// alloca; The Offset is applied as *(A + K) = B for stores, A = *(B + K) for |
13 | | /// loads, and A = B + K for copies. It is illegal on addressof constraints |
14 | | /// (because it is statically resolvable to A = &C where C = B + K) |
15 | | class AndersConstraint { |
16 | | public: |
17 | | enum ConstraintType { |
18 | | ADDR_OF, |
19 | | COPY, |
20 | | LOAD, |
21 | | STORE, |
22 | | }; |
23 | | |
24 | | private: |
25 | | ConstraintType type; |
26 | | NodeIndex dest; |
27 | | NodeIndex src; |
28 | | |
29 | | public: |
30 | | AndersConstraint(ConstraintType Ty, NodeIndex D, NodeIndex S) |
31 | 140k | : type(Ty), dest(D), src(S) {} |
32 | | |
33 | 280k | ConstraintType getType() const { return type; } |
34 | 280k | NodeIndex getDest() const { return dest; } |
35 | 326k | NodeIndex getSrc() const { return src; } |
36 | | |
37 | 0 | bool operator==(AndersConstraint const &RHS) const { |
38 | 0 | return RHS.type == type && RHS.dest == dest && RHS.src == src; |
39 | 0 | } |
40 | | |
41 | 0 | bool operator!=(AndersConstraint const &RHS) const { return !(*this == RHS); } |
42 | | |
43 | 0 | bool operator<(AndersConstraint const &RHS) const { |
44 | 0 | if (RHS.type != type) |
45 | 0 | return RHS.type < type; |
46 | 0 | else if (RHS.dest != dest) |
47 | 0 | return RHS.dest < dest; |
48 | 0 | return RHS.src < src; |
49 | 0 | } |
50 | | }; |
51 | | |
52 | | #endif |