From f2dcb3904918cf559f958f1cb4974b2702f91bb8 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Fri, 27 Apr 2018 22:19:14 -0400
Subject: [PATCH] shader_bytecode: Add decodings for i2i instructions.

---
 src/video_core/engines/shader_bytecode.h | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index fba9ab4961..0cbe5e94d5 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -25,6 +25,13 @@ struct Register {
     /// Register 255 is special cased to always be 0
     static constexpr size_t ZeroIndex = 255;
 
+    enum class Size : u64 {
+        Byte = 0,
+        Short = 1,
+        Word = 2,
+        Long = 3,
+    };
+
     constexpr Register() = default;
 
     constexpr Register(u64 value) : value(value) {}
@@ -236,6 +243,15 @@ union Instruction {
         BitField<56, 1, u64> neg_imm;
     } fset;
 
+    union {
+        BitField<10, 2, Register::Size> size;
+        BitField<13, 1, u64> is_signed;
+        BitField<41, 2, u64> selector;
+        BitField<45, 1, u64> negate_a;
+        BitField<49, 1, u64> abs_a;
+        BitField<50, 1, u64> saturate_a;
+    } i2i;
+
     BitField<61, 1, u64> is_b_imm;
     BitField<60, 1, u64> is_b_gpr;
     BitField<59, 1, u64> is_c_gpr;
@@ -314,6 +330,7 @@ public:
         FloatSet,
         FloatSetPredicate,
         IntegerSetPredicate,
+        I2I,
         Unknown,
     };
 
@@ -438,9 +455,6 @@ private:
             INST("0100110010111---", Id::I2F_C, Type::Arithmetic, "I2F_C"),
             INST("0101110010111---", Id::I2F_R, Type::Arithmetic, "I2F_R"),
             INST("0011100-10111---", Id::I2F_IMM, Type::Arithmetic, "I2F_IMM"),
-            INST("0100110011100---", Id::I2I_C, Type::Arithmetic, "I2I_C"),
-            INST("0101110011100---", Id::I2I_R, Type::Arithmetic, "I2I_R"),
-            INST("01110001-1000---", Id::I2I_IMM, Type::Arithmetic, "I2I_IMM"),
             INST("000001----------", Id::LOP32I, Type::Arithmetic, "LOP32I"),
             INST("0100110010011---", Id::MOV_C, Type::Arithmetic, "MOV_C"),
             INST("0101110010011---", Id::MOV_R, Type::Arithmetic, "MOV_R"),
@@ -449,6 +463,9 @@ private:
             INST("0100110000101---", Id::SHR_C, Type::Arithmetic, "SHR_C"),
             INST("0101110000101---", Id::SHR_R, Type::Arithmetic, "SHR_R"),
             INST("0011100-00101---", Id::SHR_IMM, Type::Arithmetic, "SHR_IMM"),
+            INST("0100110011100---", Id::I2I_C, Type::I2I, "I2I_C"),
+            INST("0101110011100---", Id::I2I_R, Type::I2I, "I2I_R"),
+            INST("01110001-1000---", Id::I2I_IMM, Type::I2I, "I2I_IMM"),
             INST("01011000--------", Id::FSET_R, Type::FloatSet, "FSET_R"),
             INST("0100100---------", Id::FSET_C, Type::FloatSet, "FSET_C"),
             INST("0011000---------", Id::FSET_IMM, Type::FloatSet, "FSET_IMM"),