radeonsi: fold si_create_function into si_llvm_create_func
authorMarek Olšák <marek.olsak@amd.com>
Sat, 11 Jan 2020 01:22:47 +0000 (20:22 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 14 Jan 2020 23:46:07 +0000 (18:46 -0500)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/gallium/drivers/radeonsi/si_compute_prim_discard.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_shader_llvm.c

index b6d92da823322d595df3a8abf17d261d00388ed3..2092510e53dabf88e605f9928c1c82c9e2fa59a8 100644 (file)
@@ -364,7 +364,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx)
        /* Create the compute shader function. */
        unsigned old_type = ctx->type;
        ctx->type = PIPE_SHADER_COMPUTE;
-       si_create_function(ctx, "prim_discard_cs", NULL, 0, THREADGROUP_SIZE);
+       si_llvm_create_func(ctx, "prim_discard_cs", NULL, 0, THREADGROUP_SIZE);
        ctx->type = old_type;
 
        if (VERTEX_COUNTER_GDS_MODE == 1) {
index 8e3b23e8109109176aaea1b0296b01d1ff0cede9..2e4cf0884ca5e9b0c0adfb9bf0d6035c7d484112 100644 (file)
@@ -3225,27 +3225,6 @@ static void si_llvm_emit_barrier(struct si_shader_context *ctx)
        ac_build_s_barrier(&ctx->ac);
 }
 
-void si_create_function(struct si_shader_context *ctx,
-                       const char *name,
-                       LLVMTypeRef *returns, unsigned num_returns,
-                       unsigned max_workgroup_size)
-{
-       si_llvm_create_func(ctx, name, returns, num_returns);
-       ctx->return_value = LLVMGetUndef(ctx->return_type);
-
-       if (ctx->screen->info.address32_hi) {
-               ac_llvm_add_target_dep_function_attr(ctx->main_fn,
-                                                    "amdgpu-32bit-address-high-bits",
-                                                    ctx->screen->info.address32_hi);
-       }
-
-       LLVMAddTargetDependentFunctionAttr(ctx->main_fn,
-                                          "no-signed-zeros-fp-math",
-                                          "true");
-
-       ac_llvm_set_workgroup_size(ctx->main_fn, max_workgroup_size);
-}
-
 static void declare_streamout_params(struct si_shader_context *ctx,
                                     struct pipe_stream_output_info *so)
 {
@@ -3811,8 +3790,8 @@ static void create_function(struct si_shader_context *ctx)
                return;
        }
 
-       si_create_function(ctx, "main", returns, num_returns,
-                          si_get_max_workgroup_size(shader));
+       si_llvm_create_func(ctx, "main", returns, num_returns,
+                           si_get_max_workgroup_size(shader));
 
        /* Reserve register locations for VGPR inputs the PS prolog may need. */
        if (ctx->type == PIPE_SHADER_FRAGMENT && !ctx->shader->is_monolithic) {
@@ -5350,8 +5329,7 @@ static void si_build_gs_prolog_function(struct si_shader_context *ctx,
        }
 
        /* Create the function. */
-       si_create_function(ctx, "gs_prolog", returns, num_sgprs + num_vgprs,
-                          0);
+       si_llvm_create_func(ctx, "gs_prolog", returns, num_sgprs + num_vgprs, 0);
        func = ctx->main_fn;
 
        /* Set the full EXEC mask for the prolog, because we are only fiddling
@@ -5535,8 +5513,8 @@ static void si_build_wrapper_function(struct si_shader_context *ctx,
                unreachable("unexpected type");
        }
 
-       si_create_function(ctx, "wrapper", returns, num_returns,
-                          si_get_max_workgroup_size(ctx->shader));
+       si_llvm_create_func(ctx, "wrapper", returns, num_returns,
+                           si_get_max_workgroup_size(ctx->shader));
 
        if (is_merged_shader(ctx))
                ac_init_exec_full_mask(&ctx->ac);
@@ -6209,7 +6187,7 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx,
                returns[num_returns++] = ctx->f32;
 
        /* Create the function. */
-       si_create_function(ctx, "vs_prolog", returns, num_returns, 0);
+       si_llvm_create_func(ctx, "vs_prolog", returns, num_returns, 0);
        func = ctx->main_fn;
 
        for (i = 0; i < num_input_vgprs; i++) {
@@ -6440,8 +6418,8 @@ static void si_build_tcs_epilog_function(struct si_shader_context *ctx,
                ac_add_arg(&ctx->args, AC_ARG_VGPR, 1, AC_ARG_INT, &tess_factors[i]);
 
        /* Create the function. */
-       si_create_function(ctx, "tcs_epilog", NULL, 0,
-                          ctx->screen->info.chip_class >= GFX7 ? 128 : 0);
+       si_llvm_create_func(ctx, "tcs_epilog", NULL, 0,
+                           ctx->screen->info.chip_class >= GFX7 ? 128 : 0);
        ac_declare_lds_as_pointer(&ctx->ac);
 
        LLVMValueRef invoc0_tess_factors[6];
@@ -6585,7 +6563,7 @@ static void si_build_ps_prolog_function(struct si_shader_context *ctx,
                return_types[num_returns++] = ctx->f32;
 
        /* Create the function. */
-       si_create_function(ctx, "ps_prolog", return_types, num_returns, 0);
+       si_llvm_create_func(ctx, "ps_prolog", return_types, num_returns, 0);
        func = ctx->main_fn;
 
        /* Copy inputs to outputs. This should be no-op, as the registers match,
@@ -6861,7 +6839,7 @@ static void si_build_ps_epilog_function(struct si_shader_context *ctx,
                ac_add_arg(&ctx->args, AC_ARG_VGPR, 1, AC_ARG_FLOAT, NULL);
 
        /* Create the function. */
-       si_create_function(ctx, "ps_epilog", NULL, 0, 0);
+       si_llvm_create_func(ctx, "ps_epilog", NULL, 0, 0);
        /* Disable elimination of unused inputs. */
        ac_llvm_add_target_dep_function_attr(ctx->main_fn,
                                             "InitialPSInputAddr", 0xffffff);
index da104678bd1e35d0b04e4af8b00558c085f751da..6f27e81a6b32a345e57d43b2e8b7e61a859d5303 100644 (file)
@@ -199,10 +199,6 @@ si_shader_context_from_abi(struct ac_shader_abi *abi)
        return container_of(abi, ctx, abi);
 }
 
-void si_create_function(struct si_shader_context *ctx,
-                       const char *name,
-                       LLVMTypeRef *returns, unsigned num_returns,
-                       unsigned max_workgroup_size);
 unsigned si_llvm_compile(LLVMModuleRef M, struct si_shader_binary *binary,
                         struct ac_llvm_compiler *compiler,
                         struct pipe_debug_callback *debug,
@@ -220,9 +216,9 @@ void si_llvm_context_init(struct si_shader_context *ctx,
 void si_llvm_context_set_ir(struct si_shader_context *ctx,
                            struct si_shader *shader);
 
-void si_llvm_create_func(struct si_shader_context *ctx,
-                        const char *name,
-                        LLVMTypeRef *return_types, unsigned num_return_elems);
+void si_llvm_create_func(struct si_shader_context *ctx, const char *name,
+                        LLVMTypeRef *return_types, unsigned num_return_elems,
+                        unsigned max_workgroup_size);
 
 void si_llvm_dispose(struct si_shader_context *ctx);
 
index 2d65c5f467105454bbd26d1b16f35335f487fda4..f831c7e8c1b79a27e79c2bc6025f398a222d11bf 100644 (file)
@@ -167,9 +167,9 @@ void si_llvm_context_set_ir(struct si_shader_context *ctx,
        ctx->num_images = util_last_bit(info->images_declared);
 }
 
-void si_llvm_create_func(struct si_shader_context *ctx,
-                        const char *name,
-                        LLVMTypeRef *return_types, unsigned num_return_elems)
+void si_llvm_create_func(struct si_shader_context *ctx, const char *name,
+                        LLVMTypeRef *return_types, unsigned num_return_elems,
+                        unsigned max_workgroup_size)
 {
        LLVMTypeRef ret_type;
        enum ac_llvm_calling_convention call_conv;
@@ -217,6 +217,19 @@ void si_llvm_create_func(struct si_shader_context *ctx,
        ctx->return_type = ret_type;
        ctx->main_fn = ac_build_main(&ctx->args, &ctx->ac, call_conv, name,
                                     ret_type, ctx->ac.module);
+       ctx->return_value = LLVMGetUndef(ctx->return_type);
+
+       if (ctx->screen->info.address32_hi) {
+               ac_llvm_add_target_dep_function_attr(ctx->main_fn,
+                                                    "amdgpu-32bit-address-high-bits",
+                                                    ctx->screen->info.address32_hi);
+       }
+
+       LLVMAddTargetDependentFunctionAttr(ctx->main_fn,
+                                          "no-signed-zeros-fp-math",
+                                          "true");
+
+       ac_llvm_set_workgroup_size(ctx->main_fn, max_workgroup_size);
 }
 
 void si_llvm_optimize_module(struct si_shader_context *ctx)