summaryrefslogtreecommitdiff
path: root/src/video_core/shader/expr.h
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-10-05 12:02:51 -0400
committerGravatar GitHub2019-10-05 12:02:51 -0400
commit47ccfabe18db3691a09f211fc4aec465ee186c2a (patch)
tree8bd02e8d5e16dee8522e29d21c711ef98282bb52 /src/video_core/shader/expr.h
parentMerge pull request #2888 from FernandoS27/decompiler2 (diff)
parentvideo_core/control_flow: Eliminate variable shadowing warnings (diff)
downloadyuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.gz
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.tar.xz
yuzu-47ccfabe18db3691a09f211fc4aec465ee186c2a.zip
Merge pull request #2944 from lioncash/ast
video_core/shader: Minor changes
Diffstat (limited to 'src/video_core/shader/expr.h')
-rw-r--r--src/video_core/shader/expr.h37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/video_core/shader/expr.h b/src/video_core/shader/expr.h
index 4c399cef9..d3dcd00ec 100644
--- a/src/video_core/shader/expr.h
+++ b/src/video_core/shader/expr.h
@@ -15,12 +15,12 @@ using Tegra::Shader::ConditionCode;
15using Tegra::Shader::Pred; 15using Tegra::Shader::Pred;
16 16
17class ExprAnd; 17class ExprAnd;
18class ExprOr; 18class ExprBoolean;
19class ExprCondCode;
19class ExprNot; 20class ExprNot;
21class ExprOr;
20class ExprPredicate; 22class ExprPredicate;
21class ExprCondCode;
22class ExprVar; 23class ExprVar;
23class ExprBoolean;
24 24
25using ExprData = 25using ExprData =
26 std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>; 26 std::variant<ExprVar, ExprCondCode, ExprPredicate, ExprNot, ExprOr, ExprAnd, ExprBoolean>;
@@ -28,9 +28,10 @@ using Expr = std::shared_ptr<ExprData>;
28 28
29class ExprAnd final { 29class ExprAnd final {
30public: 30public:
31 explicit ExprAnd(Expr a, Expr b) : operand1{a}, operand2{b} {} 31 explicit ExprAnd(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {}
32 32
33 bool operator==(const ExprAnd& b) const; 33 bool operator==(const ExprAnd& b) const;
34 bool operator!=(const ExprAnd& b) const;
34 35
35 Expr operand1; 36 Expr operand1;
36 Expr operand2; 37 Expr operand2;
@@ -38,9 +39,10 @@ public:
38 39
39class ExprOr final { 40class ExprOr final {
40public: 41public:
41 explicit ExprOr(Expr a, Expr b) : operand1{a}, operand2{b} {} 42 explicit ExprOr(Expr a, Expr b) : operand1{std::move(a)}, operand2{std::move(b)} {}
42 43
43 bool operator==(const ExprOr& b) const; 44 bool operator==(const ExprOr& b) const;
45 bool operator!=(const ExprOr& b) const;
44 46
45 Expr operand1; 47 Expr operand1;
46 Expr operand2; 48 Expr operand2;
@@ -48,9 +50,10 @@ public:
48 50
49class ExprNot final { 51class ExprNot final {
50public: 52public:
51 explicit ExprNot(Expr a) : operand1{a} {} 53 explicit ExprNot(Expr a) : operand1{std::move(a)} {}
52 54
53 bool operator==(const ExprNot& b) const; 55 bool operator==(const ExprNot& b) const;
56 bool operator!=(const ExprNot& b) const;
54 57
55 Expr operand1; 58 Expr operand1;
56}; 59};
@@ -63,6 +66,10 @@ public:
63 return var_index == b.var_index; 66 return var_index == b.var_index;
64 } 67 }
65 68
69 bool operator!=(const ExprVar& b) const {
70 return !operator==(b);
71 }
72
66 u32 var_index; 73 u32 var_index;
67}; 74};
68 75
@@ -74,6 +81,10 @@ public:
74 return predicate == b.predicate; 81 return predicate == b.predicate;
75 } 82 }
76 83
84 bool operator!=(const ExprPredicate& b) const {
85 return !operator==(b);
86 }
87
77 u32 predicate; 88 u32 predicate;
78}; 89};
79 90
@@ -85,6 +96,10 @@ public:
85 return cc == b.cc; 96 return cc == b.cc;
86 } 97 }
87 98
99 bool operator!=(const ExprCondCode& b) const {
100 return !operator==(b);
101 }
102
88 ConditionCode cc; 103 ConditionCode cc;
89}; 104};
90 105
@@ -96,6 +111,10 @@ public:
96 return value == b.value; 111 return value == b.value;
97 } 112 }
98 113
114 bool operator!=(const ExprBoolean& b) const {
115 return !operator==(b);
116 }
117
99 bool value; 118 bool value;
100}; 119};
101 120
@@ -105,9 +124,9 @@ Expr MakeExpr(Args&&... args) {
105 return std::make_shared<ExprData>(T(std::forward<Args>(args)...)); 124 return std::make_shared<ExprData>(T(std::forward<Args>(args)...));
106} 125}
107 126
108bool ExprAreEqual(Expr first, Expr second); 127bool ExprAreEqual(const Expr& first, const Expr& second);
109 128
110bool ExprAreOpposite(Expr first, Expr second); 129bool ExprAreOpposite(const Expr& first, const Expr& second);
111 130
112Expr MakeExprNot(Expr first); 131Expr MakeExprNot(Expr first);
113 132
@@ -115,6 +134,6 @@ Expr MakeExprAnd(Expr first, Expr second);
115 134
116Expr MakeExprOr(Expr first, Expr second); 135Expr MakeExprOr(Expr first, Expr second);
117 136
118bool ExprIsTrue(Expr first); 137bool ExprIsTrue(const Expr& first);
119 138
120} // namespace VideoCommon::Shader 139} // namespace VideoCommon::Shader