radeonsi: stop using lp_build_emit_llvm_unary/binary
authorMarek Olšák <marek.olsak@amd.com>
Thu, 21 Jun 2018 23:19:49 +0000 (19:19 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 25 Jun 2018 22:33:58 +0000 (18:33 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index 9bc679f3296f24e848e64ca2f3a08f24bb50b1d0..b04ad217ce37bbb4d531b6e9e1597aa907ed8a6e 100644 (file)
@@ -2141,9 +2141,8 @@ void si_load_system_value(struct si_shader_context *ctx,
                        LLVMGetParam(ctx->main_fn, SI_PARAM_POS_X_FLOAT),
                        LLVMGetParam(ctx->main_fn, SI_PARAM_POS_Y_FLOAT),
                        LLVMGetParam(ctx->main_fn, SI_PARAM_POS_Z_FLOAT),
-                       lp_build_emit_llvm_unary(&ctx->bld_base, TGSI_OPCODE_RCP,
-                                                LLVMGetParam(ctx->main_fn,
-                                                             SI_PARAM_POS_W_FLOAT)),
+                       ac_build_fdiv(&ctx->ac, ctx->ac.f32_1,
+                                     LLVMGetParam(ctx->main_fn, SI_PARAM_POS_W_FLOAT)),
                };
                value = ac_build_gather_values(&ctx->ac, pos, 4);
                break;
@@ -2164,10 +2163,8 @@ void si_load_system_value(struct si_shader_context *ctx,
                        LLVMConstReal(ctx->f32, 0),
                        LLVMConstReal(ctx->f32, 0)
                };
-               pos[0] = lp_build_emit_llvm_unary(&ctx->bld_base,
-                                                 TGSI_OPCODE_FRC, pos[0]);
-               pos[1] = lp_build_emit_llvm_unary(&ctx->bld_base,
-                                                 TGSI_OPCODE_FRC, pos[1]);
+               pos[0] = ac_build_fract(&ctx->ac, pos[0], 32);
+               pos[1] = ac_build_fract(&ctx->ac, pos[1], 32);
                value = ac_build_gather_values(&ctx->ac, pos, 4);
                break;
        }
@@ -4021,8 +4018,10 @@ static LLVMValueRef si_llvm_emit_ddxy_interp(
        for (i = 0; i < 2; i++) {
                a = LLVMBuildExtractElement(ctx->ac.builder, interp_ij,
                                            LLVMConstInt(ctx->i32, i, 0), "");
-               result[i] = lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_DDX, a);
-               result[2+i] = lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_DDY, a);
+               result[i] = ac_build_ddxy(&ctx->ac, AC_TID_MASK_TOP_LEFT, 1,
+                                         ac_to_integer(&ctx->ac, a)); /* DDX */
+               result[2+i] = ac_build_ddxy(&ctx->ac, AC_TID_MASK_TOP_LEFT, 2,
+                                           ac_to_integer(&ctx->ac, a)); /* DDY */
        }
 
        return ac_build_gather_values(&ctx->ac, result, 4);
index 3008c3ade1486bf08d65dd73e61fa2dc41f85a67..43922dc33ca81f43be0ba127371a2823afe53dce 100644 (file)
@@ -244,7 +244,9 @@ static void emit_arl(const struct lp_build_tgsi_action *action,
                     struct lp_build_emit_data *emit_data)
 {
        struct si_shader_context *ctx = si_shader_context(bld_base);
-       LLVMValueRef floor_index =  lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_FLR, emit_data->args[0]);
+       LLVMValueRef floor_index =
+               ac_build_intrinsic(&ctx->ac, "llvm.floor.f32", ctx->f32,
+                                  &emit_data->args[0], 1, AC_FUNC_ATTR_READNONE);
        emit_data->output[emit_data->chan] = LLVMBuildFPToSI(ctx->ac.builder,
                        floor_index, ctx->i32, "");
 }
@@ -556,10 +558,8 @@ static void emit_iabs(const struct lp_build_tgsi_action *action,
        struct si_shader_context *ctx = si_shader_context(bld_base);
 
        emit_data->output[emit_data->chan] =
-               lp_build_emit_llvm_binary(bld_base, TGSI_OPCODE_IMAX,
-                                         emit_data->args[0],
-                                         LLVMBuildNeg(ctx->ac.builder,
-                                                      emit_data->args[0], ""));
+               ac_build_imax(&ctx->ac,  emit_data->args[0],
+                             LLVMBuildNeg(ctx->ac.builder, emit_data->args[0], ""));
 }
 
 static void emit_minmax_int(const struct lp_build_tgsi_action *action,
@@ -668,12 +668,11 @@ static void emit_rsq(const struct lp_build_tgsi_action *action,
        struct si_shader_context *ctx = si_shader_context(bld_base);
 
        LLVMValueRef sqrt =
-               lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_SQRT,
-                                        emit_data->args[0]);
+               ac_build_intrinsic(&ctx->ac, "llvm.sqrt.f32", ctx->f32,
+                                  &emit_data->args[0], 1, AC_FUNC_ATTR_READNONE);
 
        emit_data->output[emit_data->chan] =
-               lp_build_emit_llvm_binary(bld_base, TGSI_OPCODE_DIV,
-                                         ctx->ac.f32_1, sqrt);
+               ac_build_fdiv(&ctx->ac, ctx->ac.f32_1, sqrt);
 }
 
 static void dfracexp_fetch_args(struct lp_build_tgsi_context *bld_base,
index c91bcc5697158bd1649ee68883622215aebb5784..427fead09d066ff236a39d57bc92a3b2a30d8d39 100644 (file)
@@ -1286,8 +1286,7 @@ static void tex_fetch_args(
                                                   emit_data->inst, 0,
                                                   chan);
                if (opcode == TGSI_OPCODE_TXP)
-                       args.coords[chan] = lp_build_emit_llvm_binary(
-                               bld_base, TGSI_OPCODE_DIV,
+                       args.coords[chan] = ac_build_fdiv(&ctx->ac,
                                args.coords[chan], args.coords[3]);
        }
 
@@ -1640,9 +1639,7 @@ si_lower_gather4_integer(struct si_shader_context *ctx,
                                LLVMBuildExtractElement(builder, txq_emit_data.output[0],
                                                        LLVMConstInt(ctx->i32, c, 0), "");
                        half_texel[c] = LLVMBuildUIToFP(builder, half_texel[c], ctx->f32, "");
-                       half_texel[c] =
-                               lp_build_emit_llvm_unary(&ctx->bld_base,
-                                                        TGSI_OPCODE_RCP, half_texel[c]);
+                       half_texel[c] = ac_build_fdiv(&ctx->ac, ctx->ac.f32_1, half_texel[c]);
                        half_texel[c] = LLVMBuildFMul(builder, half_texel[c],
                                                      LLVMConstReal(ctx->f32, -0.5), "");
                }