From 34a860b9e3c544ad82b8287e1b65a93c53bd7f62 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 15 Nov 2019 15:16:28 -0500 Subject: [PATCH] pan/midgard: Expose more typesize helpers Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/compiler.h | 2 ++ src/panfrost/midgard/mir.c | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index 635c0cc14c5..3c70f071814 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -518,7 +518,9 @@ unsigned mir_ubo_shift(midgard_load_store_op op); midgard_reg_mode mir_typesize(midgard_instruction *ins); midgard_reg_mode mir_srcsize(midgard_instruction *ins, unsigned i); unsigned mir_bytes_for_mode(midgard_reg_mode mode); +midgard_reg_mode mir_mode_for_destsize(unsigned size); uint16_t mir_from_bytemask(uint16_t bytemask, midgard_reg_mode mode); +uint16_t mir_to_bytemask(midgard_reg_mode mode, unsigned mask); uint16_t mir_bytemask(midgard_instruction *ins); uint16_t mir_round_bytemask_down(uint16_t mask, midgard_reg_mode mode); void mir_set_bytemask(midgard_instruction *ins, uint16_t bytemask); diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index 7c7149bd547..8d928458a54 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -283,9 +283,27 @@ mir_srcsize(midgard_instruction *ins, unsigned i) return mode; } +midgard_reg_mode +mir_mode_for_destsize(unsigned size) +{ + switch (size) { + case 8: + return midgard_reg_mode_8; + case 16: + return midgard_reg_mode_16; + case 32: + return midgard_reg_mode_32; + case 64: + return midgard_reg_mode_64; + default: + unreachable("Unknown destination size"); + } +} + + /* Converts per-component mask to a byte mask */ -static uint16_t +uint16_t mir_to_bytemask(midgard_reg_mode mode, unsigned mask) { switch (mode) { -- 2.30.2