.type = BI_BLEND,
.blend_location = nir_intrinsic_base(instr),
.src = {
+ bir_src_index(&instr->src[0]),
BIR_INDEX_REGISTER | 60 /* Can this be arbitrary? */,
- bir_src_index(&instr->src[0])
},
.src_types = {
- nir_type_uint32,
nir_type_float32,
+ nir_type_uint32
},
.swizzle = {
- { 0 },
- { 0, 1, 2, 3 }
+ { 0, 1, 2, 3 },
+ { 0 }
},
.dest = BIR_INDEX_REGISTER | 48 /* Looks like magic */,
.dest_type = nir_type_uint32,
.src = {
BIR_INDEX_CONSTANT
},
+ .src_types = {
+ instr->def.bit_size | nir_type_uint,
+ },
.constant = {
.u64 = nir_const_value_as_uint(instr->value[0], instr->def.bit_size)
}
case nir_op_u2f16:
case nir_op_u2f32:
case nir_op_u2f64:
+ case nir_op_f2f16:
+ case nir_op_f2f32:
+ case nir_op_f2f64:
+ case nir_op_f2fmp:
return BI_CONVERT;
case nir_op_vec2:
case nir_op_mov:
return BI_MOV;
+ case nir_op_fround_even:
+ case nir_op_fceil:
+ case nir_op_ffloor:
+ case nir_op_ftrunc:
+ return BI_ROUND;
+
case nir_op_frcp:
case nir_op_frsq:
- case nir_op_fsin:
- case nir_op_fcos:
return BI_SPECIAL;
default:
/* We found one, let's fuse it in */
csel->csel_cond = bcond;
bi_copy_src(csel, alu, 0, 0, constants_left, constant_shift);
- bi_copy_src(csel, alu, 1, 3, constants_left, constant_shift);
+ bi_copy_src(csel, alu, 1, 1, constants_left, constant_shift);
}
static void
unsigned constants_left = (64 / dest_bits);
unsigned constant_shift = 0;
+ if (alu.type == BI_COMBINE)
+ constants_left = 0;
+
/* Copy sources */
unsigned num_inputs = nir_op_infos[instr->op].num_inputs;
assert(num_inputs <= ARRAY_SIZE(alu.src));
- for (unsigned i = 0; i < num_inputs; ++i)
- bi_copy_src(&alu, instr, i, i, &constants_left, &constant_shift);
+ for (unsigned i = 0; i < num_inputs; ++i) {
+ unsigned f = 0;
+
+ if (i && alu.type == BI_CSEL)
+ f++;
+
+ bi_copy_src(&alu, instr, i, i + f, &constants_left, &constant_shift);
+ }
/* Op-specific fixup */
switch (instr->op) {
case nir_op_fmul:
alu.src[2] = BIR_INDEX_ZERO; /* FMA */
+ alu.src_types[2] = alu.src_types[1];
break;
case nir_op_fsat:
alu.outmod = BIFROST_SAT; /* FMOV */
case nir_op_frsq:
alu.op.special = BI_SPECIAL_FRSQ;
break;
- case nir_op_fsin:
- alu.op.special = BI_SPECIAL_FSIN;
- break;
- case nir_op_fcos:
- alu.op.special = BI_SPECIAL_FCOS;
- break;
BI_CASE_CMP(nir_op_flt)
BI_CASE_CMP(nir_op_ilt)
BI_CASE_CMP(nir_op_fge)
BI_CASE_CMP(nir_op_ine)
alu.op.compare = bi_cond_for_nir(instr->op, false);
break;
+ case nir_op_fround_even:
+ alu.op.round = BI_ROUND_MODE;
+ alu.roundmode = BIFROST_RTE;
+ break;
+ case nir_op_fceil:
+ alu.op.round = BI_ROUND_MODE;
+ alu.roundmode = BIFROST_RTP;
+ break;
+ case nir_op_ffloor:
+ alu.op.round = BI_ROUND_MODE;
+ alu.roundmode = BIFROST_RTN;
+ break;
+ case nir_op_ftrunc:
+ alu.op.round = BI_ROUND_MODE;
+ alu.roundmode = BIFROST_RTZ;
+ break;
default:
break;
}
if (alu.type == BI_CSEL) {
/* Default to csel3 */
alu.csel_cond = BI_COND_NE;
- alu.src[3] = BIR_INDEX_ZERO;
- alu.src_types[3] = alu.src_types[0];
+ alu.src[1] = BIR_INDEX_ZERO;
+ alu.src_types[1] = alu.src_types[0];
bi_fuse_csel_cond(&alu, instr->src[0],
&constants_left, &constant_shift);