From 6c4cc0cd062fbbba5349da1108d3c23cb330ca8a Mon Sep 17 00:00:00 2001
From: ReinUsesLisp <reinuseslisp@airmail.cc>
Date: Tue, 2 Feb 2021 21:07:00 -0300
Subject: shader: SSA and dominance

---
 src/shader_recompiler/frontend/ir/value.cpp | 37 +++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

(limited to 'src/shader_recompiler/frontend/ir/value.cpp')

diff --git a/src/shader_recompiler/frontend/ir/value.cpp b/src/shader_recompiler/frontend/ir/value.cpp
index 7b5b35d6c5..1e974e88c7 100644
--- a/src/shader_recompiler/frontend/ir/value.cpp
+++ b/src/shader_recompiler/frontend/ir/value.cpp
@@ -115,6 +115,43 @@ u64 Value::U64() const {
     return imm_u64;
 }
 
+bool Value::operator==(const Value& other) const {
+    if (type != other.type) {
+        return false;
+    }
+    switch (type) {
+    case Type::Void:
+        return true;
+    case Type::Opaque:
+        return inst == other.inst;
+    case Type::Label:
+        return label == other.label;
+    case Type::Reg:
+        return reg == other.reg;
+    case Type::Pred:
+        return pred == other.pred;
+    case Type::Attribute:
+        return attribute == other.attribute;
+    case Type::U1:
+        return imm_u1 == other.imm_u1;
+    case Type::U8:
+        return imm_u8 == other.imm_u8;
+    case Type::U16:
+        return imm_u16 == other.imm_u16;
+    case Type::U32:
+        return imm_u32 == other.imm_u32;
+    case Type::U64:
+        return imm_u64 == other.imm_u64;
+    case Type::ZSCO:
+        throw NotImplementedException("ZSCO comparison");
+    }
+    throw LogicError("Invalid type {}", type);
+}
+
+bool Value::operator!=(const Value& other) const {
+    return !operator==(other);
+}
+
 void Value::ValidateAccess(IR::Type expected) const {
     if (type != expected) {
         throw LogicError("Reading {} out of {}", expected, type);
-- 
cgit v1.2.3-70-g09d2