panfrost/va: add FLUSH instruction

This is needed to implement FTZ for intermediate values on valhall.

Signed-off-by: Benjamin Lee <benjamin.lee@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32470>
This commit is contained in:
Benjamin Lee
2024-12-02 15:19:45 -08:00
committed by Marge Bot
parent 9f17138571
commit c9de3d57f7
3 changed files with 40 additions and 3 deletions

View File

@@ -34,6 +34,7 @@
#include "util/u_worklist.h"
#include "bi_opcodes.h"
#include "bifrost.h"
#include "valhall_enums.h"
#ifdef __cplusplus
extern "C" {
@@ -473,9 +474,11 @@ typedef struct {
bool format; /* LEA_TEX */
struct {
enum bi_special special; /* FADD_RSCALE, FMA_RSCALE */
enum bi_round round; /* FMA, converts, FADD, _RSCALE, etc */
bool ftz; /* Flush-to-zero for F16_TO_F32 */
enum bi_special special; /* FADD_RSCALE, FMA_RSCALE */
enum bi_round round; /* FMA, converts, FADD, _RSCALE, etc */
bool ftz; /* Flush-to-zero for F16_TO_F32 and FLUSH */
enum va_nan_mode nan_mode; /* NaN flush mode, for FLUSH */
bool flush_inf; /* Flush infinity to finite, for FLUSH */
};
struct {

View File

@@ -778,6 +778,16 @@
<value desc="Set bottom bit">aor1</value>
</enum>
<enum name="NaN mode">
<desc>
Flush specific NaN values in FLUSH.f32 and FLUSH.v2f16. flush_nan flushes
all NaN values to zero. quiet_nan flushes signaling NaNs to quiet NaNs.
</desc>
<value desc="None">none</value>
<value desc="Flush NaN">flush_nan</value>
<value desc="Quiet NaN">quiet_nan</value>
</enum>
<!-- note that the `unused="true"` annotation here just means that this
particular entry is unused by the compiler. This may be because the
instruction isn't generated yet, but it may also be because there
@@ -1691,6 +1701,21 @@
<subgroup/>
</ins>
<group name = "FLUSH" title="Flush floats" dests="1" opcode="0x98" unit="CVT">
<ins name="FLUSH.f32" opcode2="0"/>
<ins name="FLUSH.v2f16" opcode2="1"/>
<desc>
Flush special float values. The ftz modifier flushes subnormal values to
zero. The flush_inf modifier flushes +inf to the maximum finite value, and
-inf to the minimum finite value. nan_mode may flush either all NaN values
to zero or signaling NaNs to quiet NaNs depending on the mode.
</desc>
<va_mod name="nan_mode" start="8" size="2"/>
<va_mod name="ftz" start="10" size="1"/>
<va_mod name="flush_inf" start="11" size="1"/>
<src float="true" absneg="true" swizzle="true"/>
</group>
<group name="FREXP" title="Fraction/exponent extract" dests="1" opcode="0x99" unused="true" unit="CVT">
<ins name="FREXPM.f32" opcode2="0"/>
<ins name="FREXPM.v2f16" opcode2="1"/>

View File

@@ -427,6 +427,15 @@ va_pack_alu(const bi_instr *I)
hex |= 1ull << 25;
break;
case BI_OPCODE_FLUSH_F32:
case BI_OPCODE_FLUSH_V2F16:
hex |= I->nan_mode << 8;
if (I->ftz)
hex |= 1ull << 10;
if (I->flush_inf)
hex |= 1ull << 11;
break;
/* Add mux type */
case BI_OPCODE_MUX_I32:
case BI_OPCODE_MUX_V2I16: