freedreno/ir3: add helpers to deal with src/dst types
[mesa.git] / src / freedreno / ir3 / ir3.h
index 2fb21b67d4da8fcc0453f5062d9f54e4b2201366..d6ff469b26ef1328c4d7c46d4197f32e0e2dd7ee 100644 (file)
@@ -595,6 +595,9 @@ unsigned ir3_count_instructions_ra(struct ir3 *ir);
 
 void ir3_find_ssa_uses(struct ir3 *ir, void *mem_ctx, bool falsedeps);
 
+void ir3_set_dst_type(struct ir3_instruction *instr, bool half);
+void ir3_fixup_src_type(struct ir3_instruction *instr);
+
 #include "util/set.h"
 #define foreach_ssa_use(__use, __instr) \
        for (struct ir3_instruction *__use = (void *)~0; \
@@ -830,6 +833,54 @@ static inline bool is_bool(struct ir3_instruction *instr)
        }
 }
 
+static inline opc_t
+cat3_half_opc(opc_t opc)
+{
+       switch (opc) {
+       case OPC_MAD_F32: return OPC_MAD_F16;
+       case OPC_SEL_B32: return OPC_SEL_B16;
+       case OPC_SEL_S32: return OPC_SEL_S16;
+       case OPC_SEL_F32: return OPC_SEL_F16;
+       case OPC_SAD_S32: return OPC_SAD_S16;
+       default:          return opc;
+       }
+}
+
+static inline opc_t
+cat3_full_opc(opc_t opc)
+{
+       switch (opc) {
+       case OPC_MAD_F16: return OPC_MAD_F32;
+       case OPC_SEL_B16: return OPC_SEL_B32;
+       case OPC_SEL_S16: return OPC_SEL_S32;
+       case OPC_SEL_F16: return OPC_SEL_F32;
+       case OPC_SAD_S16: return OPC_SAD_S32;
+       default:          return opc;
+       }
+}
+
+static inline opc_t
+cat4_half_opc(opc_t opc)
+{
+       switch (opc) {
+       case OPC_RSQ:  return OPC_HRSQ;
+       case OPC_LOG2: return OPC_HLOG2;
+       case OPC_EXP2: return OPC_HEXP2;
+       default:       return opc;
+       }
+}
+
+static inline opc_t
+cat4_full_opc(opc_t opc)
+{
+       switch (opc) {
+       case OPC_HRSQ:  return OPC_RSQ;
+       case OPC_HLOG2: return OPC_LOG2;
+       case OPC_HEXP2: return OPC_EXP2;
+       default:        return opc;
+       }
+}
+
 static inline bool is_meta(struct ir3_instruction *instr)
 {
        return (opc_cat(instr->opc) == -1);