From be94ee88d227d0d3dbeabe9ade98bacd910c7a7e Mon Sep 17 00:00:00 2001
From: ReinUsesLisp <reinuseslisp@airmail.cc>
Date: Fri, 5 Feb 2021 19:19:36 -0300
Subject: shader: Make typed IR

---
 src/shader_recompiler/frontend/ir/opcode.inc | 200 +++++++++++++++------------
 1 file changed, 113 insertions(+), 87 deletions(-)

(limited to 'src/shader_recompiler/frontend/ir/opcode.inc')

diff --git a/src/shader_recompiler/frontend/ir/opcode.inc b/src/shader_recompiler/frontend/ir/opcode.inc
index 4596bf39f7..6eb105d929 100644
--- a/src/shader_recompiler/frontend/ir/opcode.inc
+++ b/src/shader_recompiler/frontend/ir/opcode.inc
@@ -52,15 +52,15 @@ OPCODE(LoadGlobalS8,                                        U32,            U64,
 OPCODE(LoadGlobalU16,                                       U32,            U64,                                                            )
 OPCODE(LoadGlobalS16,                                       U32,            U64,                                                            )
 OPCODE(LoadGlobal32,                                        U32,            U64,                                                            )
-OPCODE(LoadGlobal64,                                        Opaque,         U64,                                                            )
-OPCODE(LoadGlobal128,                                       Opaque,         U64,                                                            )
+OPCODE(LoadGlobal64,                                        U32x2,          U64,                                                            )
+OPCODE(LoadGlobal128,                                       U32x4,          U64,                                                            )
 OPCODE(WriteGlobalU8,                                       Void,           U64,            U32,                                            )
 OPCODE(WriteGlobalS8,                                       Void,           U64,            U32,                                            )
 OPCODE(WriteGlobalU16,                                      Void,           U64,            U32,                                            )
 OPCODE(WriteGlobalS16,                                      Void,           U64,            U32,                                            )
 OPCODE(WriteGlobal32,                                       Void,           U64,            U32,                                            )
-OPCODE(WriteGlobal64,                                       Void,           U64,            Opaque,                                         )
-OPCODE(WriteGlobal128,                                      Void,           U64,            Opaque,                                         )
+OPCODE(WriteGlobal64,                                       Void,           U64,            U32x2,                                          )
+OPCODE(WriteGlobal128,                                      Void,           U64,            U32x4,                                          )
 
 // Storage buffer operations
 OPCODE(LoadStorageU8,                                       U32,            U32,            U32,                                            )
@@ -68,21 +68,41 @@ OPCODE(LoadStorageS8,                                       U32,            U32,
 OPCODE(LoadStorageU16,                                      U32,            U32,            U32,                                            )
 OPCODE(LoadStorageS16,                                      U32,            U32,            U32,                                            )
 OPCODE(LoadStorage32,                                       U32,            U32,            U32,                                            )
-OPCODE(LoadStorage64,                                       Opaque,         U32,            U32,                                            )
-OPCODE(LoadStorage128,                                      Opaque,         U32,            U32,                                            )
-OPCODE(WriteStorageU8,                                      Void,           U32,            U32,            U32,                                            )
-OPCODE(WriteStorageS8,                                      Void,           U32,            U32,            U32,                                            )
-OPCODE(WriteStorageU16,                                     Void,           U32,            U32,            U32,                                            )
-OPCODE(WriteStorageS16,                                     Void,           U32,            U32,            U32,                                            )
-OPCODE(WriteStorage32,                                      Void,           U32,            U32,            U32,                                            )
-OPCODE(WriteStorage64,                                      Void,           U32,            U32,            Opaque,                                         )
-OPCODE(WriteStorage128,                                     Void,           U32,            U32,            Opaque,                                         )
+OPCODE(LoadStorage64,                                       U32x2,          U32,            U32,                                            )
+OPCODE(LoadStorage128,                                      U32x4,          U32,            U32,                                            )
+OPCODE(WriteStorageU8,                                      Void,           U32,            U32,            U32,                            )
+OPCODE(WriteStorageS8,                                      Void,           U32,            U32,            U32,                            )
+OPCODE(WriteStorageU16,                                     Void,           U32,            U32,            U32,                            )
+OPCODE(WriteStorageS16,                                     Void,           U32,            U32,            U32,                            )
+OPCODE(WriteStorage32,                                      Void,           U32,            U32,            U32,                            )
+OPCODE(WriteStorage64,                                      Void,           U32,            U32,            U32x2,                          )
+OPCODE(WriteStorage128,                                     Void,           U32,            U32,            U32x4,                          )
 
 // Vector utility
-OPCODE(CompositeConstruct2,                                 Opaque,         Opaque,         Opaque,                                         )
-OPCODE(CompositeConstruct3,                                 Opaque,         Opaque,         Opaque,         Opaque,                         )
-OPCODE(CompositeConstruct4,                                 Opaque,         Opaque,         Opaque,         Opaque,         Opaque,         )
-OPCODE(CompositeExtract,                                    Opaque,         Opaque,         U32,                                            )
+OPCODE(CompositeConstructU32x2,                             U32x2,          U32,            U32,                                            )
+OPCODE(CompositeConstructU32x3,                             U32x3,          U32,            U32,            U32,                            )
+OPCODE(CompositeConstructU32x4,                             U32x4,          U32,            U32,            U32,            U32,            )
+OPCODE(CompositeExtractU32x2,                               U32,            U32x2,          U32,                                            )
+OPCODE(CompositeExtractU32x3,                               U32,            U32x3,          U32,                                            )
+OPCODE(CompositeExtractU32x4,                               U32,            U32x4,          U32,                                            )
+OPCODE(CompositeConstructF16x2,                             F16x2,          F16,            F16,                                            )
+OPCODE(CompositeConstructF16x3,                             F16x3,          F16,            F16,            F16,                            )
+OPCODE(CompositeConstructF16x4,                             F16x4,          F16,            F16,            F16,            F16,            )
+OPCODE(CompositeExtractF16x2,                               F16,            F16x2,          U32,                                            )
+OPCODE(CompositeExtractF16x3,                               F16,            F16x3,          U32,                                            )
+OPCODE(CompositeExtractF16x4,                               F16,            F16x4,          U32,                                            )
+OPCODE(CompositeConstructF32x2,                             F32x2,          F32,            F32,                                            )
+OPCODE(CompositeConstructF32x3,                             F32x3,          F32,            F32,            F32,                            )
+OPCODE(CompositeConstructF32x4,                             F32x4,          F32,            F32,            F32,            F32,            )
+OPCODE(CompositeExtractF32x2,                               F32,            F32x2,          U32,                                            )
+OPCODE(CompositeExtractF32x3,                               F32,            F32x3,          U32,                                            )
+OPCODE(CompositeExtractF32x4,                               F32,            F32x4,          U32,                                            )
+OPCODE(CompositeConstructF64x2,                             F64x2,          F64,            F64,                                            )
+OPCODE(CompositeConstructF64x3,                             F64x3,          F64,            F64,            F64,                            )
+OPCODE(CompositeConstructF64x4,                             F64x4,          F64,            F64,            F64,            F64,            )
+OPCODE(CompositeExtractF64x2,                               F64,            F64x2,          U32,                                            )
+OPCODE(CompositeExtractF64x3,                               F64,            F64x3,          U32,                                            )
+OPCODE(CompositeExtractF64x4,                               F64,            F64x4,          U32,                                            )
 
 // Select operations
 OPCODE(Select8,                                             U8,             U1,             U8,             U8,                             )
@@ -91,12 +111,18 @@ OPCODE(Select32,                                            U32,            U1,
 OPCODE(Select64,                                            U64,            U1,             U64,            U64,                            )
 
 // Bitwise conversions
-OPCODE(PackUint2x32,                                        U64,            Opaque,                                                         )
-OPCODE(UnpackUint2x32,                                      Opaque,         U64,                                                            )
-OPCODE(PackFloat2x16,                                       U32,            Opaque,                                                         )
-OPCODE(UnpackFloat2x16,                                     Opaque,         U32,                                                            )
-OPCODE(PackDouble2x32,                                      U64,            Opaque,                                                         )
-OPCODE(UnpackDouble2x32,                                    Opaque,         U64,                                                            )
+OPCODE(BitCastU16F16,                                       U16,            F16,                                                            )
+OPCODE(BitCastU32F32,                                       U32,            F32,                                                            )
+OPCODE(BitCastU64F64,                                       U64,            F64,                                                            )
+OPCODE(BitCastF16U16,                                       F16,            U16,                                                            )
+OPCODE(BitCastF32U32,                                       F32,            U32,                                                            )
+OPCODE(BitCastF64U64,                                       F64,            U64,                                                            )
+OPCODE(PackUint2x32,                                        U64,            U32x2,                                                          )
+OPCODE(UnpackUint2x32,                                      U32x2,          U64,                                                            )
+OPCODE(PackFloat2x16,                                       U32,            F16x2,                                                          )
+OPCODE(UnpackFloat2x16,                                     F16x2,          U32,                                                            )
+OPCODE(PackDouble2x32,                                      U64,            U32x2,                                                          )
+OPCODE(UnpackDouble2x32,                                    U32x2,          U64,                                                            )
 
 // Pseudo-operation, handled specially at final emit
 OPCODE(GetZeroFromOp,                                       U1,             Opaque,                                                         )
@@ -105,52 +131,52 @@ OPCODE(GetCarryFromOp,                                      U1,             Opaq
 OPCODE(GetOverflowFromOp,                                   U1,             Opaque,                                                         )
 
 // Floating-point operations
-OPCODE(FPAbs16,                                             U16,            U16,                                                            )
-OPCODE(FPAbs32,                                             U32,            U32,                                                            )
-OPCODE(FPAbs64,                                             U64,            U64,                                                            )
-OPCODE(FPAdd16,                                             U16,            U16,            U16,                                            )
-OPCODE(FPAdd32,                                             U32,            U32,            U32,                                            )
-OPCODE(FPAdd64,                                             U64,            U64,            U64,                                            )
-OPCODE(FPFma16,                                             U16,            U16,            U16,            U16,                            )
-OPCODE(FPFma32,                                             U32,            U32,            U32,            U32,                            )
-OPCODE(FPFma64,                                             U64,            U64,            U64,            U64,                            )
-OPCODE(FPMax32,                                             U32,            U32,            U32,                                            )
-OPCODE(FPMax64,                                             U64,            U64,            U64,                                            )
-OPCODE(FPMin32,                                             U32,            U32,            U32,                                            )
-OPCODE(FPMin64,                                             U64,            U64,            U64,                                            )
-OPCODE(FPMul16,                                             U16,            U16,            U16,                                            )
-OPCODE(FPMul32,                                             U32,            U32,            U32,                                            )
-OPCODE(FPMul64,                                             U64,            U64,            U64,                                            )
-OPCODE(FPNeg16,                                             U16,            U16,                                                            )
-OPCODE(FPNeg32,                                             U32,            U32,                                                            )
-OPCODE(FPNeg64,                                             U64,            U64,                                                            )
-OPCODE(FPRecip32,                                           U32,            U32,                                                            )
-OPCODE(FPRecip64,                                           U64,            U64,                                                            )
-OPCODE(FPRecipSqrt32,                                       U32,            U32,                                                            )
-OPCODE(FPRecipSqrt64,                                       U64,            U64,                                                            )
-OPCODE(FPSqrt,                                              U32,            U32,                                                            )
-OPCODE(FPSin,                                               U32,            U32,                                                            )
-OPCODE(FPSinNotReduced,                                     U32,            U32,                                                            )
-OPCODE(FPExp2,                                              U32,            U32,                                                            )
-OPCODE(FPExp2NotReduced,                                    U32,            U32,                                                            )
-OPCODE(FPCos,                                               U32,            U32,                                                            )
-OPCODE(FPCosNotReduced,                                     U32,            U32,                                                            )
-OPCODE(FPLog2,                                              U32,            U32,                                                            )
-OPCODE(FPSaturate16,                                        U16,            U16,                                                            )
-OPCODE(FPSaturate32,                                        U32,            U32,                                                            )
-OPCODE(FPSaturate64,                                        U64,            U64,                                                            )
-OPCODE(FPRoundEven16,                                       U16,            U16,                                                            )
-OPCODE(FPRoundEven32,                                       U32,            U32,                                                            )
-OPCODE(FPRoundEven64,                                       U64,            U64,                                                            )
-OPCODE(FPFloor16,                                           U16,            U16,                                                            )
-OPCODE(FPFloor32,                                           U32,            U32,                                                            )
-OPCODE(FPFloor64,                                           U64,            U64,                                                            )
-OPCODE(FPCeil16,                                            U16,            U16,                                                            )
-OPCODE(FPCeil32,                                            U32,            U32,                                                            )
-OPCODE(FPCeil64,                                            U64,            U64,                                                            )
-OPCODE(FPTrunc16,                                           U16,            U16,                                                            )
-OPCODE(FPTrunc32,                                           U32,            U32,                                                            )
-OPCODE(FPTrunc64,                                           U64,            U64,                                                            )
+OPCODE(FPAbs16,                                             F16,            F16,                                                            )
+OPCODE(FPAbs32,                                             F32,            F32,                                                            )
+OPCODE(FPAbs64,                                             F64,            F64,                                                            )
+OPCODE(FPAdd16,                                             F16,            F16,            F16,                                            )
+OPCODE(FPAdd32,                                             F32,            F32,            F32,                                            )
+OPCODE(FPAdd64,                                             F64,            F64,            F64,                                            )
+OPCODE(FPFma16,                                             F16,            F16,            F16,            F16,                            )
+OPCODE(FPFma32,                                             F32,            F32,            F32,            F32,                            )
+OPCODE(FPFma64,                                             F64,            F64,            F64,            F64,                            )
+OPCODE(FPMax32,                                             F32,            F32,            F32,                                            )
+OPCODE(FPMax64,                                             F64,            F64,            F64,                                            )
+OPCODE(FPMin32,                                             F32,            F32,            F32,                                            )
+OPCODE(FPMin64,                                             F64,            F64,            F64,                                            )
+OPCODE(FPMul16,                                             F16,            F16,            F16,                                            )
+OPCODE(FPMul32,                                             F32,            F32,            F32,                                            )
+OPCODE(FPMul64,                                             F64,            F64,            F64,                                            )
+OPCODE(FPNeg16,                                             F16,            F16,                                                            )
+OPCODE(FPNeg32,                                             F32,            F32,                                                            )
+OPCODE(FPNeg64,                                             F64,            F64,                                                            )
+OPCODE(FPRecip32,                                           F32,            F32,                                                            )
+OPCODE(FPRecip64,                                           F64,            F64,                                                            )
+OPCODE(FPRecipSqrt32,                                       F32,            F32,                                                            )
+OPCODE(FPRecipSqrt64,                                       F64,            F64,                                                            )
+OPCODE(FPSqrt,                                              F32,            F32,                                                            )
+OPCODE(FPSin,                                               F32,            F32,                                                            )
+OPCODE(FPSinNotReduced,                                     F32,            F32,                                                            )
+OPCODE(FPExp2,                                              F32,            F32,                                                            )
+OPCODE(FPExp2NotReduced,                                    F32,            F32,                                                            )
+OPCODE(FPCos,                                               F32,            F32,                                                            )
+OPCODE(FPCosNotReduced,                                     F32,            F32,                                                            )
+OPCODE(FPLog2,                                              F32,            F32,                                                            )
+OPCODE(FPSaturate16,                                        F16,            F16,                                                            )
+OPCODE(FPSaturate32,                                        F32,            F32,                                                            )
+OPCODE(FPSaturate64,                                        F64,            F64,                                                            )
+OPCODE(FPRoundEven16,                                       F16,            F16,                                                            )
+OPCODE(FPRoundEven32,                                       F32,            F32,                                                            )
+OPCODE(FPRoundEven64,                                       F64,            F64,                                                            )
+OPCODE(FPFloor16,                                           F16,            F16,                                                            )
+OPCODE(FPFloor32,                                           F32,            F32,                                                            )
+OPCODE(FPFloor64,                                           F64,            F64,                                                            )
+OPCODE(FPCeil16,                                            F16,            F16,                                                            )
+OPCODE(FPCeil32,                                            F32,            F32,                                                            )
+OPCODE(FPCeil64,                                            F64,            F64,                                                            )
+OPCODE(FPTrunc16,                                           F16,            F16,                                                            )
+OPCODE(FPTrunc32,                                           F32,            F32,                                                            )
+OPCODE(FPTrunc64,                                           F64,            F64,                                                            )
 
 // Integer operations
 OPCODE(IAdd32,                                              U32,            U32,            U32,                                            )
@@ -188,24 +214,24 @@ OPCODE(LogicalXor,                                          U1,             U1,
 OPCODE(LogicalNot,                                          U1,             U1,                                                             )
 
 // Conversion operations
-OPCODE(ConvertS16F16,                                       U32,            U16,                                                            )
-OPCODE(ConvertS16F32,                                       U32,            U32,                                                            )
-OPCODE(ConvertS16F64,                                       U32,            U64,                                                            )
-OPCODE(ConvertS32F16,                                       U32,            U16,                                                            )
-OPCODE(ConvertS32F32,                                       U32,            U32,                                                            )
-OPCODE(ConvertS32F64,                                       U32,            U64,                                                            )
-OPCODE(ConvertS64F16,                                       U64,            U16,                                                            )
-OPCODE(ConvertS64F32,                                       U64,            U32,                                                            )
-OPCODE(ConvertS64F64,                                       U64,            U64,                                                            )
-OPCODE(ConvertU16F16,                                       U32,            U16,                                                            )
-OPCODE(ConvertU16F32,                                       U32,            U32,                                                            )
-OPCODE(ConvertU16F64,                                       U32,            U64,                                                            )
-OPCODE(ConvertU32F16,                                       U32,            U16,                                                            )
-OPCODE(ConvertU32F32,                                       U32,            U32,                                                            )
-OPCODE(ConvertU32F64,                                       U32,            U64,                                                            )
-OPCODE(ConvertU64F16,                                       U64,            U16,                                                            )
-OPCODE(ConvertU64F32,                                       U64,            U32,                                                            )
-OPCODE(ConvertU64F64,                                       U64,            U64,                                                            )
+OPCODE(ConvertS16F16,                                       U32,            F16,                                                            )
+OPCODE(ConvertS16F32,                                       U32,            F32,                                                            )
+OPCODE(ConvertS16F64,                                       U32,            F64,                                                            )
+OPCODE(ConvertS32F16,                                       U32,            F16,                                                            )
+OPCODE(ConvertS32F32,                                       U32,            F32,                                                            )
+OPCODE(ConvertS32F64,                                       U32,            F64,                                                            )
+OPCODE(ConvertS64F16,                                       U64,            F16,                                                            )
+OPCODE(ConvertS64F32,                                       U64,            F32,                                                            )
+OPCODE(ConvertS64F64,                                       U64,            F64,                                                            )
+OPCODE(ConvertU16F16,                                       U32,            F16,                                                            )
+OPCODE(ConvertU16F32,                                       U32,            F32,                                                            )
+OPCODE(ConvertU16F64,                                       U32,            F64,                                                            )
+OPCODE(ConvertU32F16,                                       U32,            F16,                                                            )
+OPCODE(ConvertU32F32,                                       U32,            F32,                                                            )
+OPCODE(ConvertU32F64,                                       U32,            F64,                                                            )
+OPCODE(ConvertU64F16,                                       U64,            F16,                                                            )
+OPCODE(ConvertU64F32,                                       U64,            F32,                                                            )
+OPCODE(ConvertU64F64,                                       U64,            F64,                                                            )
 
 OPCODE(ConvertU64U32,                                       U64,            U32,                                                            )
 OPCODE(ConvertU32U64,                                       U32,            U64,                                                            )
-- 
cgit v1.2.3-70-g09d2