[Mesa-dev] [PATCH 11/17] amd/common: replace add_sgpr_argument() by add_arg()

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Dec 20 19:56:01 UTC 2017


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/common/ac_nir_to_llvm.c | 78 +++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 45 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 49e5d0be93..b7c2420802 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -281,25 +281,6 @@ add_arg(struct arg_info *info, enum ac_arg_regfile regfile, LLVMTypeRef type,
 	}
 }
 
-static inline void
-add_argument(struct arg_info *info,
-	     LLVMTypeRef type, LLVMValueRef *param_ptr)
-{
-	assert(info->count < MAX_ARGS);
-	info->assign[info->count] = param_ptr;
-	info->types[info->count] = type;
-	info->count++;
-}
-
-static inline void
-add_sgpr_argument(struct arg_info *info,
-		  LLVMTypeRef type, LLVMValueRef *param_ptr)
-{
-	add_argument(info, type, param_ptr);
-	info->num_sgprs_used += ac_get_type_size(type) / 4;
-	info->sgpr_count++;
-}
-
 static inline void
 add_user_sgpr_array_argument(struct arg_info *info,
 			     LLVMTypeRef type,
@@ -794,13 +775,13 @@ static void create_function(struct nir_to_llvm_context *ctx,
 		for (int i = 0; i < 3; i++) {
 			ctx->workgroup_ids[i] = NULL;
 			if (ctx->shader_info->info.cs.uses_block_id[i]) {
-				add_sgpr_argument(&args, ctx->ac.i32,
-						  &ctx->workgroup_ids[i]);
+				add_arg(&args, ARG_SGPR, ctx->ac.i32,
+					&ctx->workgroup_ids[i]);
 			}
 		}
 
 		if (ctx->shader_info->info.cs.uses_local_invocation_idx)
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->tg_size);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->tg_size);
 		add_arg(&args, ARG_VGPR, ctx->ac.v3i32,
 			&ctx->local_invocation_ids);
 		break;
@@ -814,7 +795,8 @@ static void create_function(struct nir_to_llvm_context *ctx,
 		if (ctx->shader_info->info.needs_multiview_view_index || (!ctx->options->key.vs.as_es && !ctx->options->key.vs.as_ls && ctx->options->key.has_multiview_view_index))
 			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index);
 		if (ctx->options->key.vs.as_es)
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->es2gs_offset); // es2gs offset
+			add_arg(&args, ARG_SGPR, ctx->ac.i32,
+				&ctx->es2gs_offset);
 		else if (ctx->options->key.vs.as_ls)
 			add_arg(&args, ARG_SGPR, ctx->ac.i32,
 				&ctx->ls_out_layout);
@@ -824,13 +806,15 @@ static void create_function(struct nir_to_llvm_context *ctx,
 	case MESA_SHADER_TESS_CTRL:
 		if (has_previous_stage) {
 			// First 6 system regs
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->oc_lds); // param oc lds
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->merged_wave_info); // merged wave info
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->tess_factor_offset); // tess factor offset
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->oc_lds);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32,
+				&ctx->merged_wave_info);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32,
+				&ctx->tess_factor_offset);
 
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); // scratch offset
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL); // scratch offset
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL); // unknown
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL); // unknown
 
 			declare_global_input_sgprs(ctx, stage,
 						   has_previous_stage,
@@ -881,8 +865,9 @@ static void create_function(struct nir_to_llvm_context *ctx,
 				add_arg(&args, ARG_SGPR, ctx->ac.i32,
 					&ctx->view_index);
 
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->oc_lds); // param oc lds
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->tess_factor_offset); // tess factor offset
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->oc_lds);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32,
+				&ctx->tess_factor_offset);
 			add_arg(&args, ARG_VGPR, ctx->ac.i32,
 				&ctx->tcs_patch_id);
 			add_arg(&args, ARG_VGPR, ctx->ac.i32,
@@ -899,25 +884,28 @@ static void create_function(struct nir_to_llvm_context *ctx,
 			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->view_index);
 
 		if (ctx->options->key.tes.as_es) {
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->oc_lds); // OC LDS
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); //
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->es2gs_offset); // es2gs offset
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->oc_lds);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32,
+				&ctx->es2gs_offset);
 		} else {
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); //
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->oc_lds); // OC LDS
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->oc_lds);
 		}
 		declare_tes_input_vgprs(ctx, &args);
 		break;
 	case MESA_SHADER_GEOMETRY:
 		if (has_previous_stage) {
 			// First 6 system regs
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->gs2vs_offset); // tess factor offset
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->merged_wave_info); // merged wave info
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->oc_lds); // param oc lds
+			add_arg(&args, ARG_SGPR, ctx->ac.i32,
+				&ctx->gs2vs_offset);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32,
+				&ctx->merged_wave_info);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->oc_lds);
 
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); // scratch offset
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
-			add_sgpr_argument(&args, ctx->ac.i32, NULL); // unknown
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL); // scratch offset
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL); // unknown
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, NULL); // unknown
 
 			declare_global_input_sgprs(ctx, stage,
 						   has_previous_stage,
@@ -974,8 +962,8 @@ static void create_function(struct nir_to_llvm_context *ctx,
 				add_arg(&args, ARG_SGPR, ctx->ac.i32,
 					&ctx->view_index);
 
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->gs2vs_offset); // gs2vs offset
-			add_sgpr_argument(&args, ctx->ac.i32, &ctx->gs_wave_id); // wave id
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->gs2vs_offset);
+			add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->gs_wave_id);
 			add_arg(&args, ARG_VGPR, ctx->ac.i32,
 				&ctx->gs_vtx_offset[0]);
 			add_arg(&args, ARG_VGPR, ctx->ac.i32,
@@ -1003,7 +991,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
 			add_arg(&args, ARG_SGPR, ctx->ac.i32,
 				&ctx->sample_pos_offset);
 
-		add_sgpr_argument(&args, ctx->ac.i32, &ctx->prim_mask); /* prim mask */
+		add_arg(&args, ARG_SGPR, ctx->ac.i32, &ctx->prim_mask);
 		add_arg(&args, ARG_VGPR, ctx->ac.v2i32, &ctx->persp_sample);
 		add_arg(&args, ARG_VGPR, ctx->ac.v2i32, &ctx->persp_center);
 		add_arg(&args, ARG_VGPR, ctx->ac.v2i32, &ctx->persp_centroid);
-- 
2.15.1



More information about the mesa-dev mailing list