Commit 9491c754 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Emulate b2f32

parent 88617078
......@@ -1003,6 +1003,20 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
break;
}
/* We don't have a native b2f32 instruction. Instead, like many GPUs,
* we exploit booleans as 0/~0 for false/true, and correspondingly AND
* by 1.0 to do the type conversion. For the moment, prime us to emit:
*
* iand [whatever], #0
*
* At the end of emit_alu (as MIR), we'll fix-up the constant */
case nir_op_b2f32: {
op = midgard_alu_op_iand;
components = 0;
break;
}
default:
printf("Unhandled ALU op %s\n", nir_op_infos[instr->op].name);
assert(0);
......@@ -1066,6 +1080,21 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
ins.alu = alu;
/* Late fixup for emulated instructions */
if (instr->op == nir_op_b2f32) {
/* Presently, our second argument is an inline #0 constant.
* Switch over to an embedded 1.0 constant (that can't fit
* inline, since we're 32-bit, not 16-bit like the inline
* constants) */
ins.ssa_args.inline_constant = false;
ins.ssa_args.src1 = SSA_FIXED_REGISTER(REGISTER_CONSTANT);
ins.has_constants = true;
ins.constants[0] = 1.0;
}
if (_unit == UNIT_VLUT) {
/* To avoid duplicating the LUTs (we think?), LUT instructions can only
* operate as if they were scalars. Lower them here by changing the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment