panfrost/midgard: Add fround(_even), ftrunc, ffma

These ops were discovered by invoking the correspondingly names GLSL
functions. The rounding ops here behave exact as expected and are mapped
to their corresponding NIR ops where applicable. The ffma behaves as a
LUT instruction and requires some special argument packing (since
Midgard normally only allows for 2 arguments); this quirk will be
addressed in the future, but for now FMA is still lowered.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
This commit is contained in:
Alyssa Rosenzweig
2019-02-23 01:12:10 +00:00
parent 4a4726af3c
commit c6be9969d2
3 changed files with 14 additions and 0 deletions

View File

@@ -195,8 +195,12 @@ static unsigned alu_opcode_props[256] = {
[midgard_alu_op_imin] = UNITS_MOST,
[midgard_alu_op_imax] = UNITS_MOST,
[midgard_alu_op_fmov] = UNITS_ALL | QUIRK_FLIPPED_R24,
[midgard_alu_op_fround] = UNITS_ADD,
[midgard_alu_op_froundeven] = UNITS_ADD,
[midgard_alu_op_ftrunc] = UNITS_ADD,
[midgard_alu_op_ffloor] = UNITS_ADD,
[midgard_alu_op_fceil] = UNITS_ADD,
[midgard_alu_op_ffma] = UNIT_VLUT,
/* Though they output a scalar, they need to run on a vector unit
* since they process vectors */

View File

@@ -55,8 +55,11 @@ typedef enum {
midgard_alu_op_fmin = 0x28,
midgard_alu_op_fmax = 0x2C,
midgard_alu_op_fmov = 0x30,
midgard_alu_op_froundeven = 0x34,
midgard_alu_op_ftrunc = 0x35,
midgard_alu_op_ffloor = 0x36,
midgard_alu_op_fceil = 0x37,
midgard_alu_op_ffma = 0x38,
midgard_alu_op_fdot3 = 0x3C,
midgard_alu_op_fdot3r = 0x3D,
midgard_alu_op_fdot4 = 0x3E,
@@ -98,6 +101,7 @@ typedef enum {
midgard_alu_op_u2f = 0xBC,
midgard_alu_op_icsel = 0xC1,
midgard_alu_op_fcsel = 0xC5,
midgard_alu_op_fround = 0xC6,
midgard_alu_op_fatan_pt2 = 0xE8,
midgard_alu_op_frcp = 0xF0,
midgard_alu_op_frsqrt = 0xF2,
@@ -402,8 +406,11 @@ static char *alu_opcode_names[256] = {
[midgard_alu_op_fmin] = "fmin",
[midgard_alu_op_fmax] = "fmax",
[midgard_alu_op_fmov] = "fmov",
[midgard_alu_op_froundeven] = "froundeven",
[midgard_alu_op_ftrunc] = "ftrunc",
[midgard_alu_op_ffloor] = "ffloor",
[midgard_alu_op_fceil] = "fceil",
[midgard_alu_op_ffma] = "ffma",
[midgard_alu_op_fdot3] = "fdot3",
[midgard_alu_op_fdot3r] = "fdot3r",
[midgard_alu_op_fdot4] = "fdot4",
@@ -445,6 +452,7 @@ static char *alu_opcode_names[256] = {
[midgard_alu_op_u2f] = "u2f",
[midgard_alu_op_icsel] = "icsel",
[midgard_alu_op_fcsel] = "fcsel",
[midgard_alu_op_fround] = "fround",
[midgard_alu_op_fatan_pt2] = "fatan_pt2",
[midgard_alu_op_frcp] = "frcp",
[midgard_alu_op_frsqrt] = "frsqrt",

View File

@@ -950,6 +950,8 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
ALU_CASE(imax, imax);
ALU_CASE(fmov, fmov);
ALU_CASE(ffloor, ffloor);
ALU_CASE(fround_even, froundeven);
ALU_CASE(ftrunc, ftrunc);
ALU_CASE(fceil, fceil);
ALU_CASE(fdot3, fdot3);
ALU_CASE(fdot4, fdot4);