radeonsi: inline si_llvm_shader_type into si_llvm_create_func
authorMarek Olšák <marek.olsak@amd.com>
Thu, 27 Apr 2017 00:12:48 +0000 (02:12 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 4 May 2017 22:23:44 +0000 (00:23 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index f9b9405259753aae6ff93aebdf9b9b33c8d13646..ece9a74163fc4b6049bef1ec32853ce1268d1ad0 100644 (file)
@@ -5706,7 +5706,6 @@ static void si_create_function(struct si_shader_context *ctx,
 
        si_llvm_create_func(ctx, name, returns, num_returns,
                            params, num_params);
-       si_llvm_shader_type(ctx->main_fn, ctx->type);
        ctx->return_value = LLVMGetUndef(ctx->return_type);
 
        for (i = 0; i <= last_sgpr; ++i) {
index b54db20c704de40d25519c97b1be47ab183d7d7c..35315caac6beabd2e5481155c523f2403568567b 100644 (file)
@@ -240,7 +240,6 @@ si_shader_context(struct lp_build_tgsi_context *bld_base)
 }
 
 void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
-void si_llvm_shader_type(LLVMValueRef F, unsigned type);
 
 LLVMTargetRef si_llvm_get_amdgpu_target(const char *triple);
 
index 2b0d6001fd5c24ff13755b2bb170c002cea5682a..de671ef80d6ed6f38f95d0c024d4beea28f7d1ae 100644 (file)
@@ -65,37 +65,6 @@ void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value)
        LLVMAddTargetDependentFunctionAttr(F, name, str);
 }
 
-/**
- * Set the shader type we want to compile
- *
- * @param type shader type to set
- */
-void si_llvm_shader_type(LLVMValueRef F, unsigned type)
-{
-       enum si_llvm_calling_convention calling_conv;
-
-       switch (type) {
-       case PIPE_SHADER_VERTEX:
-       case PIPE_SHADER_TESS_CTRL:
-       case PIPE_SHADER_TESS_EVAL:
-               calling_conv = RADEON_LLVM_AMDGPU_VS;
-               break;
-       case PIPE_SHADER_GEOMETRY:
-               calling_conv = RADEON_LLVM_AMDGPU_GS;
-               break;
-       case PIPE_SHADER_FRAGMENT:
-               calling_conv = RADEON_LLVM_AMDGPU_PS;
-               break;
-       case PIPE_SHADER_COMPUTE:
-               calling_conv = RADEON_LLVM_AMDGPU_CS;
-               break;
-       default:
-               unreachable("Unhandle shader type");
-       }
-
-       LLVMSetFunctionCallConv(F, calling_conv);
-}
-
 static void init_amdgpu_target()
 {
        gallivm_init_llvm_targets();
@@ -1392,6 +1361,7 @@ void si_llvm_create_func(struct si_shader_context *ctx,
 {
        LLVMTypeRef main_fn_type, ret_type;
        LLVMBasicBlockRef main_fn_body;
+       enum si_llvm_calling_convention call_conv;
 
        if (num_return_elems)
                ret_type = LLVMStructTypeInContext(ctx->gallivm.context,
@@ -1407,6 +1377,27 @@ void si_llvm_create_func(struct si_shader_context *ctx,
        main_fn_body = LLVMAppendBasicBlockInContext(ctx->gallivm.context,
                        ctx->main_fn, "main_body");
        LLVMPositionBuilderAtEnd(ctx->gallivm.builder, main_fn_body);
+
+       switch (ctx->type) {
+       case PIPE_SHADER_VERTEX:
+       case PIPE_SHADER_TESS_CTRL:
+       case PIPE_SHADER_TESS_EVAL:
+               call_conv = RADEON_LLVM_AMDGPU_VS;
+               break;
+       case PIPE_SHADER_GEOMETRY:
+               call_conv = RADEON_LLVM_AMDGPU_GS;
+               break;
+       case PIPE_SHADER_FRAGMENT:
+               call_conv = RADEON_LLVM_AMDGPU_PS;
+               break;
+       case PIPE_SHADER_COMPUTE:
+               call_conv = RADEON_LLVM_AMDGPU_CS;
+               break;
+       default:
+               unreachable("Unhandle shader type");
+       }
+
+       LLVMSetFunctionCallConv(ctx->main_fn, call_conv);
 }
 
 void si_llvm_optimize_module(struct si_shader_context *ctx)