-
- tmp_src = get_internal_temp_repl(ctx, &tmp_dst);
-
- if (is_const(src))
- src = get_unconst(ctx, src);
-
- get_immediate(ctx, &constval0, fui(0.0));
- get_immediate(ctx, &constval1, fui(1.0));
- get_immediate(ctx, &constval128, fui(128.0));
-
- /* max.f tmp.y, src.y, {0.0} */
- instr = ir3_instr_create(ctx->ir, 2, OPC_MAX_F);
- add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_Y);
- add_src_reg(ctx, instr, src, TGSI_SWIZZLE_Y);
- add_src_reg(ctx, instr, &constval0, constval0.SwizzleX);
-
- /* nop */
- ir3_instr_create(ctx->ir, 0, OPC_NOP);
-
- /* max.f tmp.z, src.w, {-128.0} */
- instr = ir3_instr_create(ctx->ir, 2, OPC_MAX_F);
- add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_Z);
- add_src_reg(ctx, instr, src, TGSI_SWIZZLE_W);
- add_src_reg(ctx, instr, &constval128,
- constval128.SwizzleX)->flags |= IR3_REG_NEGATE;
-
- /* cmps.f.ge tmp.w, (neg)src.x, {0.0} */
- instr = ir3_instr_create(ctx->ir, 2, OPC_CMPS_F);
- add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_W);
- add_src_reg(ctx, instr, src, TGSI_SWIZZLE_X)->flags |= IR3_REG_NEGATE;
- add_src_reg(ctx, instr, &constval0, constval0.SwizzleX);
- instr->cat2.condition = IR3_COND_GE;
-
- /* max.f dst.y, src.x, {0.0} */
- instr = ir3_instr_create(ctx->ir, 2, OPC_MAX_F);
- add_dst_reg(ctx, instr, dst, TGSI_SWIZZLE_Y);
- add_src_reg(ctx, instr, src, TGSI_SWIZZLE_X);
- add_src_reg(ctx, instr, &constval0, constval0.SwizzleX);
-
- /* nop */
- ir3_instr_create(ctx->ir, 0, OPC_NOP);
-
- /* min.f tmp.x, tmp.z, {128.0} */
- instr = ir3_instr_create(ctx->ir, 2, OPC_MIN_F);
- add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_X);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_Z);
- add_src_reg(ctx, instr, &constval128, constval128.SwizzleX);
-
- /* add.s tmp.z, tmp.w, -1 */
- instr = ir3_instr_create(ctx->ir, 2, OPC_ADD_S);
- add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_Z);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_W);
- ir3_reg_create(instr, 0, IR3_REG_IMMED)->iim_val = -1;
-
- /* log2 tmp.y, tmp.y */
- instr = ir3_instr_create(ctx->ir, 4, OPC_LOG2);
- r = add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_Y);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_Y);
- regmask_set(ctx->needs_ss, r, TGSI_WRITEMASK_Y);
-
- /* (rpt1)nop */
- ir3_instr_create(ctx->ir, 0, OPC_NOP)->repeat = 1;
-
- /* (ss)mul.f tmp.x, tmp.x, tmp.y */
- instr = ir3_instr_create(ctx->ir, 2, OPC_MUL_F);
- add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_X);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_X);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_Y);
-
- /* mov.f16f16 dst.x, {1.0} */
- instr = ir3_instr_create(ctx->ir, 1, 0);
- instr->cat1.src_type = get_ftype(ctx);
- instr->cat1.dst_type = get_ftype(ctx);
- add_dst_reg(ctx, instr, dst, TGSI_SWIZZLE_X);
- add_src_reg(ctx, instr, &constval1, constval1.SwizzleX);
-
- /* mov.f16f16 dst.w, {1.0} */
- instr = ir3_instr_create(ctx->ir, 1, 0);
- instr->cat1.src_type = get_ftype(ctx);
- instr->cat1.dst_type = get_ftype(ctx);
- add_dst_reg(ctx, instr, dst, TGSI_SWIZZLE_W);
- add_src_reg(ctx, instr, &constval1, constval1.SwizzleX);
-
- /* (rpt3)nop */
- ir3_instr_create(ctx->ir, 0, OPC_NOP)->repeat = 3;
-
- /* exp2 tmp.x, tmp.x */
- instr = ir3_instr_create(ctx->ir, 4, OPC_EXP2);
- r = add_dst_reg(ctx, instr, &tmp_dst, TGSI_SWIZZLE_X);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_X);
- regmask_set(ctx->needs_ss, r, TGSI_WRITEMASK_X);
-
- /* (ss)sel.f16 dst.z, {0.0}, tmp.z, tmp.x */
- instr = ir3_instr_create(ctx->ir, 3,
- ctx->so->half_precision ? OPC_SEL_F16 : OPC_SEL_F32);
- add_dst_reg(ctx, instr, dst, TGSI_SWIZZLE_Z);
- add_src_reg(ctx, instr, &constval0, constval0.SwizzleX);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_Z);
- add_src_reg(ctx, instr, tmp_src, TGSI_SWIZZLE_X);
-
- put_dst(ctx, inst, dst);
-}
-
-static inline void
-get_swiz(unsigned *swiz, struct tgsi_src_register *src)
-{
- swiz[0] = src->SwizzleX;
- swiz[1] = src->SwizzleY;
- swiz[2] = src->SwizzleZ;
- swiz[3] = src->SwizzleW;
-}
-
-static void
-trans_dotp(const struct instr_translater *t,
- struct fd3_compile_context *ctx,
- struct tgsi_full_instruction *inst)
-{
- struct ir3_instruction *instr;
- struct tgsi_dst_register tmp_dst;
- struct tgsi_src_register *tmp_src;
- struct tgsi_dst_register *dst = &inst->Dst[0].Register;