nir: Expose double and int64 op_to_options_mask helpers

We already have one internally for int64 but we don't have a similar one
for doubles so we'll have to make one.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Jason Ekstrand
2019-03-01 17:39:54 -06:00
committed by Jason Ekstrand
parent ca2b5e9069
commit ebb3695376
3 changed files with 23 additions and 51 deletions

View File

@@ -3271,8 +3271,10 @@ bool nir_lower_bit_size(nir_shader *shader,
nir_lower_bit_size_callback callback,
void *callback_data);
nir_lower_int64_options nir_lower_int64_op_to_options_mask(nir_op opcode);
bool nir_lower_int64(nir_shader *shader, nir_lower_int64_options options);
nir_lower_doubles_options nir_lower_doubles_op_to_options_mask(nir_op opcode);
bool nir_lower_doubles(nir_shader *shader, nir_lower_doubles_options options);
bool nir_lower_pack(nir_shader *shader);

View File

@@ -589,6 +589,23 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr,
return true;
}
nir_lower_doubles_options
nir_lower_doubles_op_to_options_mask(nir_op opcode)
{
switch (opcode) {
case nir_op_frcp: return nir_lower_drcp;
case nir_op_fsqrt: return nir_lower_dsqrt;
case nir_op_frsq: return nir_lower_drsq;
case nir_op_ftrunc: return nir_lower_dtrunc;
case nir_op_ffloor: return nir_lower_dfloor;
case nir_op_fceil: return nir_lower_dceil;
case nir_op_ffract: return nir_lower_dfract;
case nir_op_fround_even: return nir_lower_dround_even;
case nir_op_fmod: return nir_lower_dmod;
default: return 0;
}
}
static bool
lower_doubles_instr(nir_builder *b, nir_alu_instr *instr,
nir_lower_doubles_options options)
@@ -607,55 +624,8 @@ lower_doubles_instr(nir_builder *b, nir_alu_instr *instr,
if (lower_doubles_instr_to_soft(b, instr, options))
return true;
switch (instr->op) {
case nir_op_frcp:
if (!(options & nir_lower_drcp))
return false;
break;
case nir_op_fsqrt:
if (!(options & nir_lower_dsqrt))
return false;
break;
case nir_op_frsq:
if (!(options & nir_lower_drsq))
return false;
break;
case nir_op_ftrunc:
if (!(options & nir_lower_dtrunc))
return false;
break;
case nir_op_ffloor:
if (!(options & nir_lower_dfloor))
return false;
break;
case nir_op_fceil:
if (!(options & nir_lower_dceil))
return false;
break;
case nir_op_ffract:
if (!(options & nir_lower_dfract))
return false;
break;
case nir_op_fround_even:
if (!(options & nir_lower_dround_even))
return false;
break;
case nir_op_fmod:
if (!(options & nir_lower_dmod))
return false;
break;
default:
if (!(options & nir_lower_doubles_op_to_options_mask(instr->op)))
return false;
}
b->cursor = nir_before_instr(&instr->instr);

View File

@@ -630,8 +630,8 @@ lower_irem64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d)
return nir_bcsel(b, n_is_neg, nir_ineg(b, r), r);
}
static nir_lower_int64_options
opcode_to_options_mask(nir_op opcode)
nir_lower_int64_options
nir_lower_int64_op_to_options_mask(nir_op opcode)
{
switch (opcode) {
case nir_op_imul:
@@ -834,7 +834,7 @@ lower_int64_impl(nir_function_impl *impl, nir_lower_int64_options options)
break;
}
if (!(options & opcode_to_options_mask(alu->op)))
if (!(options & nir_lower_int64_op_to_options_mask(alu->op)))
continue;
b.cursor = nir_before_instr(instr);