[2/9] ac: rename LLVM <= 7 helpers for readability

Submitted by Marek Olšák on June 4, 2019, 12:02 a.m.

Details

Message ID 20190604000258.9143-2-maraeo@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Marek Olšák June 4, 2019, 12:02 a.m.
From: Marek Olšák <marek.olsak@amd.com>

---
 src/amd/common/ac_llvm_build.c | 74 +++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 37 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 79058f53b4e..2a1a133c392 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1100,30 +1100,30 @@  LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx,
 }
 
 /* See ac_build_load_custom() documentation. */
 LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx,
 				   LLVMValueRef base_ptr, LLVMValueRef index)
 {
 	return ac_build_load_custom(ctx, base_ptr, index, true, true, false);
 }
 
 static void
-ac_build_buffer_store_common(struct ac_llvm_context *ctx,
-			     LLVMValueRef rsrc,
-			     LLVMValueRef data,
-			     LLVMValueRef vindex,
-			     LLVMValueRef voffset,
-			     unsigned num_channels,
-			     bool glc,
-			     bool slc,
-			     bool writeonly_memory,
-			     bool use_format)
+ac_build_llvm7_buffer_store_common(struct ac_llvm_context *ctx,
+				   LLVMValueRef rsrc,
+				   LLVMValueRef data,
+				   LLVMValueRef vindex,
+				   LLVMValueRef voffset,
+				   unsigned num_channels,
+				   bool glc,
+				   bool slc,
+				   bool writeonly_memory,
+				   bool use_format)
 {
 	LLVMValueRef args[] = {
 		data,
 		LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
 		vindex ? vindex : ctx->i32_0,
 		voffset,
 		LLVMConstInt(ctx->i1, glc, 0),
 		LLVMConstInt(ctx->i1, slc, 0)
 	};
 	unsigned func = CLAMP(num_channels, 1, 3) - 1;
@@ -1195,23 +1195,23 @@  ac_build_buffer_store_format(struct ac_llvm_context *ctx,
 			     unsigned num_channels,
 			     bool glc,
 			     bool writeonly_memory)
 {
 	if (HAVE_LLVM >= 0x800) {
 		ac_build_llvm8_buffer_store_common(ctx, rsrc, data, vindex,
 						   voffset, NULL, num_channels,
 						   ctx->f32, glc, false,
 						   writeonly_memory, true, true);
 	} else {
-		ac_build_buffer_store_common(ctx, rsrc, data, vindex, voffset,
-					     num_channels, glc, false,
-					     writeonly_memory, true);
+		ac_build_llvm7_buffer_store_common(ctx, rsrc, data, vindex, voffset,
+						   num_channels, glc, false,
+						   writeonly_memory, true);
 	}
 }
 
 /* TBUFFER_STORE_FORMAT_{X,XY,XYZ,XYZW} <- the suffix is selected by num_channels=1..4.
  * The type of vdata must be one of i32 (num_channels=1), v2i32 (num_channels=2),
  * or v4i32 (num_channels=3,4).
  */
 void
 ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
 			    LLVMValueRef rsrc,
@@ -1264,54 +1264,54 @@  ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
 							   voffset, offset,
 							   num_channels,
 							   ctx->f32,
 							   glc, slc,
 							   writeonly_memory,
 							   false, false);
 		} else {
 			if (voffset)
 				offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
 
-			ac_build_buffer_store_common(ctx, rsrc,
-						     ac_to_float(ctx, vdata),
-						     ctx->i32_0, offset,
-						     num_channels, glc, slc,
-						     writeonly_memory, false);
+			ac_build_llvm7_buffer_store_common(ctx, rsrc,
+							   ac_to_float(ctx, vdata),
+							   ctx->i32_0, offset,
+							   num_channels, glc, slc,
+							   writeonly_memory, false);
 		}
 		return;
 	}
 
 	static const unsigned dfmts[] = {
 		V_008F0C_BUF_DATA_FORMAT_32,
 		V_008F0C_BUF_DATA_FORMAT_32_32,
 		V_008F0C_BUF_DATA_FORMAT_32_32_32,
 		V_008F0C_BUF_DATA_FORMAT_32_32_32_32
 	};
 	unsigned dfmt = dfmts[num_channels - 1];
 	unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
 	LLVMValueRef immoffset = LLVMConstInt(ctx->i32, inst_offset, 0);
 
 	ac_build_raw_tbuffer_store(ctx, rsrc, vdata, voffset, soffset,
 			           immoffset, num_channels, dfmt, nfmt, glc,
 				   slc, writeonly_memory);
 }
 
 static LLVMValueRef
-ac_build_buffer_load_common(struct ac_llvm_context *ctx,
-			    LLVMValueRef rsrc,
-			    LLVMValueRef vindex,
-			    LLVMValueRef voffset,
-			    unsigned num_channels,
-			    bool glc,
-			    bool slc,
-			    bool can_speculate,
-			    bool use_format)
+ac_build_llvm7_buffer_load_common(struct ac_llvm_context *ctx,
+				  LLVMValueRef rsrc,
+				  LLVMValueRef vindex,
+				  LLVMValueRef voffset,
+				  unsigned num_channels,
+				  bool glc,
+				  bool slc,
+				  bool can_speculate,
+				  bool use_format)
 {
 	LLVMValueRef args[] = {
 		LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
 		vindex ? vindex : ctx->i32_0,
 		voffset,
 		LLVMConstInt(ctx->i1, glc, 0),
 		LLVMConstInt(ctx->i1, slc, 0)
 	};
 	unsigned func = CLAMP(num_channels, 1, 3) - 1;
 
@@ -1427,42 +1427,42 @@  ac_build_buffer_load(struct ac_llvm_context *ctx,
 
 	if (HAVE_LLVM >= 0x0800) {
 		return ac_build_llvm8_buffer_load_common(ctx, rsrc, vindex,
 							 offset, ctx->i32_0,
 							 num_channels, ctx->f32,
 							 glc, slc,
 							 can_speculate, false,
 							 false);
 	}
 
-	return ac_build_buffer_load_common(ctx, rsrc, vindex, offset,
-					   num_channels, glc, slc,
-					   can_speculate, false);
+	return ac_build_llvm7_buffer_load_common(ctx, rsrc, vindex, offset,
+						 num_channels, glc, slc,
+						 can_speculate, false);
 }
 
 LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx,
 					 LLVMValueRef rsrc,
 					 LLVMValueRef vindex,
 					 LLVMValueRef voffset,
 					 unsigned num_channels,
 					 bool glc,
 					 bool can_speculate)
 {
 	if (HAVE_LLVM >= 0x800) {
 		return ac_build_llvm8_buffer_load_common(ctx, rsrc, vindex, voffset, ctx->i32_0,
 							 num_channels, ctx->f32,
 							 glc, false,
 							 can_speculate, true, true);
 	}
-	return ac_build_buffer_load_common(ctx, rsrc, vindex, voffset,
-					   num_channels, glc, false,
-					   can_speculate, true);
+	return ac_build_llvm7_buffer_load_common(ctx, rsrc, vindex, voffset,
+						 num_channels, glc, false,
+						 can_speculate, true);
 }
 
 LLVMValueRef ac_build_buffer_load_format_gfx9_safe(struct ac_llvm_context *ctx,
                                                   LLVMValueRef rsrc,
                                                   LLVMValueRef vindex,
                                                   LLVMValueRef voffset,
                                                   unsigned num_channels,
                                                   bool glc,
                                                   bool can_speculate)
 {
@@ -1477,23 +1477,23 @@  LLVMValueRef ac_build_buffer_load_format_gfx9_safe(struct ac_llvm_context *ctx,
 	LLVMValueRef stride = LLVMBuildExtractElement(ctx->builder, rsrc, ctx->i32_1, "");
 	stride = LLVMBuildLShr(ctx->builder, stride, LLVMConstInt(ctx->i32, 16, 0), "");
 
 	LLVMValueRef new_elem_count = LLVMBuildSelect(ctx->builder,
 	                                              LLVMBuildICmp(ctx->builder, LLVMIntUGT, elem_count, stride, ""),
 	                                              elem_count, stride, "");
 
 	LLVMValueRef new_rsrc = LLVMBuildInsertElement(ctx->builder, rsrc, new_elem_count,
 	                                               LLVMConstInt(ctx->i32, 2, 0), "");
 
-	return ac_build_buffer_load_common(ctx, new_rsrc, vindex, voffset,
-	                                   num_channels, glc, false,
-	                                   can_speculate, true);
+	return ac_build_llvm7_buffer_load_common(ctx, new_rsrc, vindex, voffset,
+						 num_channels, glc, false,
+						 can_speculate, true);
 }
 
 static LLVMValueRef
 ac_build_llvm8_tbuffer_load(struct ac_llvm_context *ctx,
 			    LLVMValueRef rsrc,
 			    LLVMValueRef vindex,
 			    LLVMValueRef voffset,
 			    LLVMValueRef soffset,
 			    unsigned num_channels,
 			    unsigned dfmt,
@@ -1804,21 +1804,21 @@  ac_build_opencoded_load_format(struct ac_llvm_context *ctx,
 		if (HAVE_LLVM >= 0x0800) {
 			LLVMTypeRef channel_type = load_log_size == 0 ? ctx->i8 :
 						   load_log_size == 1 ? ctx->i16 : ctx->i32;
 			unsigned num_channels = 1 << (MAX2(load_log_size, 2) - 2);
 			loads[i] = ac_build_llvm8_buffer_load_common(
 					ctx, rsrc, vindex, voffset, tmp,
 					num_channels, channel_type, glc, slc,
 					can_speculate, false, true);
 		} else {
 			tmp = LLVMBuildAdd(ctx->builder, voffset, tmp, "");
-			loads[i] = ac_build_buffer_load_common(
+			loads[i] = ac_build_llvm7_buffer_load_common(
 					ctx, rsrc, vindex, tmp,
 					1 << (load_log_size - 2), glc, slc, can_speculate, false);
 		}
 		if (load_log_size >= 2)
 			loads[i] = ac_to_integer(ctx, loads[i]);
 	}
 
 	if (log_recombine > 0) {
 		/* Recombine bytes if necessary (GFX6 only) */
 		LLVMTypeRef dst_type = log_recombine == 2 ? ctx->i32 : ctx->i16;

Comments

Patches 1-2:

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>

On 6/4/19 2:02 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak@amd.com>
>
> ---
>   src/amd/common/ac_llvm_build.c | 74 +++++++++++++++++-----------------
>   1 file changed, 37 insertions(+), 37 deletions(-)
>
> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
> index 79058f53b4e..2a1a133c392 100644
> --- a/src/amd/common/ac_llvm_build.c
> +++ b/src/amd/common/ac_llvm_build.c
> @@ -1100,30 +1100,30 @@ LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx,
>   }
>   
>   /* See ac_build_load_custom() documentation. */
>   LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx,
>   				   LLVMValueRef base_ptr, LLVMValueRef index)
>   {
>   	return ac_build_load_custom(ctx, base_ptr, index, true, true, false);
>   }
>   
>   static void
> -ac_build_buffer_store_common(struct ac_llvm_context *ctx,
> -			     LLVMValueRef rsrc,
> -			     LLVMValueRef data,
> -			     LLVMValueRef vindex,
> -			     LLVMValueRef voffset,
> -			     unsigned num_channels,
> -			     bool glc,
> -			     bool slc,
> -			     bool writeonly_memory,
> -			     bool use_format)
> +ac_build_llvm7_buffer_store_common(struct ac_llvm_context *ctx,
> +				   LLVMValueRef rsrc,
> +				   LLVMValueRef data,
> +				   LLVMValueRef vindex,
> +				   LLVMValueRef voffset,
> +				   unsigned num_channels,
> +				   bool glc,
> +				   bool slc,
> +				   bool writeonly_memory,
> +				   bool use_format)
>   {
>   	LLVMValueRef args[] = {
>   		data,
>   		LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>   		vindex ? vindex : ctx->i32_0,
>   		voffset,
>   		LLVMConstInt(ctx->i1, glc, 0),
>   		LLVMConstInt(ctx->i1, slc, 0)
>   	};
>   	unsigned func = CLAMP(num_channels, 1, 3) - 1;
> @@ -1195,23 +1195,23 @@ ac_build_buffer_store_format(struct ac_llvm_context *ctx,
>   			     unsigned num_channels,
>   			     bool glc,
>   			     bool writeonly_memory)
>   {
>   	if (HAVE_LLVM >= 0x800) {
>   		ac_build_llvm8_buffer_store_common(ctx, rsrc, data, vindex,
>   						   voffset, NULL, num_channels,
>   						   ctx->f32, glc, false,
>   						   writeonly_memory, true, true);
>   	} else {
> -		ac_build_buffer_store_common(ctx, rsrc, data, vindex, voffset,
> -					     num_channels, glc, false,
> -					     writeonly_memory, true);
> +		ac_build_llvm7_buffer_store_common(ctx, rsrc, data, vindex, voffset,
> +						   num_channels, glc, false,
> +						   writeonly_memory, true);
>   	}
>   }
>   
>   /* TBUFFER_STORE_FORMAT_{X,XY,XYZ,XYZW} <- the suffix is selected by num_channels=1..4.
>    * The type of vdata must be one of i32 (num_channels=1), v2i32 (num_channels=2),
>    * or v4i32 (num_channels=3,4).
>    */
>   void
>   ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
>   			    LLVMValueRef rsrc,
> @@ -1264,54 +1264,54 @@ ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
>   							   voffset, offset,
>   							   num_channels,
>   							   ctx->f32,
>   							   glc, slc,
>   							   writeonly_memory,
>   							   false, false);
>   		} else {
>   			if (voffset)
>   				offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
>   
> -			ac_build_buffer_store_common(ctx, rsrc,
> -						     ac_to_float(ctx, vdata),
> -						     ctx->i32_0, offset,
> -						     num_channels, glc, slc,
> -						     writeonly_memory, false);
> +			ac_build_llvm7_buffer_store_common(ctx, rsrc,
> +							   ac_to_float(ctx, vdata),
> +							   ctx->i32_0, offset,
> +							   num_channels, glc, slc,
> +							   writeonly_memory, false);
>   		}
>   		return;
>   	}
>   
>   	static const unsigned dfmts[] = {
>   		V_008F0C_BUF_DATA_FORMAT_32,
>   		V_008F0C_BUF_DATA_FORMAT_32_32,
>   		V_008F0C_BUF_DATA_FORMAT_32_32_32,
>   		V_008F0C_BUF_DATA_FORMAT_32_32_32_32
>   	};
>   	unsigned dfmt = dfmts[num_channels - 1];
>   	unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
>   	LLVMValueRef immoffset = LLVMConstInt(ctx->i32, inst_offset, 0);
>   
>   	ac_build_raw_tbuffer_store(ctx, rsrc, vdata, voffset, soffset,
>   			           immoffset, num_channels, dfmt, nfmt, glc,
>   				   slc, writeonly_memory);
>   }
>   
>   static LLVMValueRef
> -ac_build_buffer_load_common(struct ac_llvm_context *ctx,
> -			    LLVMValueRef rsrc,
> -			    LLVMValueRef vindex,
> -			    LLVMValueRef voffset,
> -			    unsigned num_channels,
> -			    bool glc,
> -			    bool slc,
> -			    bool can_speculate,
> -			    bool use_format)
> +ac_build_llvm7_buffer_load_common(struct ac_llvm_context *ctx,
> +				  LLVMValueRef rsrc,
> +				  LLVMValueRef vindex,
> +				  LLVMValueRef voffset,
> +				  unsigned num_channels,
> +				  bool glc,
> +				  bool slc,
> +				  bool can_speculate,
> +				  bool use_format)
>   {
>   	LLVMValueRef args[] = {
>   		LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>   		vindex ? vindex : ctx->i32_0,
>   		voffset,
>   		LLVMConstInt(ctx->i1, glc, 0),
>   		LLVMConstInt(ctx->i1, slc, 0)
>   	};
>   	unsigned func = CLAMP(num_channels, 1, 3) - 1;
>   
> @@ -1427,42 +1427,42 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
>   
>   	if (HAVE_LLVM >= 0x0800) {
>   		return ac_build_llvm8_buffer_load_common(ctx, rsrc, vindex,
>   							 offset, ctx->i32_0,
>   							 num_channels, ctx->f32,
>   							 glc, slc,
>   							 can_speculate, false,
>   							 false);
>   	}
>   
> -	return ac_build_buffer_load_common(ctx, rsrc, vindex, offset,
> -					   num_channels, glc, slc,
> -					   can_speculate, false);
> +	return ac_build_llvm7_buffer_load_common(ctx, rsrc, vindex, offset,
> +						 num_channels, glc, slc,
> +						 can_speculate, false);
>   }
>   
>   LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx,
>   					 LLVMValueRef rsrc,
>   					 LLVMValueRef vindex,
>   					 LLVMValueRef voffset,
>   					 unsigned num_channels,
>   					 bool glc,
>   					 bool can_speculate)
>   {
>   	if (HAVE_LLVM >= 0x800) {
>   		return ac_build_llvm8_buffer_load_common(ctx, rsrc, vindex, voffset, ctx->i32_0,
>   							 num_channels, ctx->f32,
>   							 glc, false,
>   							 can_speculate, true, true);
>   	}
> -	return ac_build_buffer_load_common(ctx, rsrc, vindex, voffset,
> -					   num_channels, glc, false,
> -					   can_speculate, true);
> +	return ac_build_llvm7_buffer_load_common(ctx, rsrc, vindex, voffset,
> +						 num_channels, glc, false,
> +						 can_speculate, true);
>   }
>   
>   LLVMValueRef ac_build_buffer_load_format_gfx9_safe(struct ac_llvm_context *ctx,
>                                                     LLVMValueRef rsrc,
>                                                     LLVMValueRef vindex,
>                                                     LLVMValueRef voffset,
>                                                     unsigned num_channels,
>                                                     bool glc,
>                                                     bool can_speculate)
>   {
> @@ -1477,23 +1477,23 @@ LLVMValueRef ac_build_buffer_load_format_gfx9_safe(struct ac_llvm_context *ctx,
>   	LLVMValueRef stride = LLVMBuildExtractElement(ctx->builder, rsrc, ctx->i32_1, "");
>   	stride = LLVMBuildLShr(ctx->builder, stride, LLVMConstInt(ctx->i32, 16, 0), "");
>   
>   	LLVMValueRef new_elem_count = LLVMBuildSelect(ctx->builder,
>   	                                              LLVMBuildICmp(ctx->builder, LLVMIntUGT, elem_count, stride, ""),
>   	                                              elem_count, stride, "");
>   
>   	LLVMValueRef new_rsrc = LLVMBuildInsertElement(ctx->builder, rsrc, new_elem_count,
>   	                                               LLVMConstInt(ctx->i32, 2, 0), "");
>   
> -	return ac_build_buffer_load_common(ctx, new_rsrc, vindex, voffset,
> -	                                   num_channels, glc, false,
> -	                                   can_speculate, true);
> +	return ac_build_llvm7_buffer_load_common(ctx, new_rsrc, vindex, voffset,
> +						 num_channels, glc, false,
> +						 can_speculate, true);
>   }
>   
>   static LLVMValueRef
>   ac_build_llvm8_tbuffer_load(struct ac_llvm_context *ctx,
>   			    LLVMValueRef rsrc,
>   			    LLVMValueRef vindex,
>   			    LLVMValueRef voffset,
>   			    LLVMValueRef soffset,
>   			    unsigned num_channels,
>   			    unsigned dfmt,
> @@ -1804,21 +1804,21 @@ ac_build_opencoded_load_format(struct ac_llvm_context *ctx,
>   		if (HAVE_LLVM >= 0x0800) {
>   			LLVMTypeRef channel_type = load_log_size == 0 ? ctx->i8 :
>   						   load_log_size == 1 ? ctx->i16 : ctx->i32;
>   			unsigned num_channels = 1 << (MAX2(load_log_size, 2) - 2);
>   			loads[i] = ac_build_llvm8_buffer_load_common(
>   					ctx, rsrc, vindex, voffset, tmp,
>   					num_channels, channel_type, glc, slc,
>   					can_speculate, false, true);
>   		} else {
>   			tmp = LLVMBuildAdd(ctx->builder, voffset, tmp, "");
> -			loads[i] = ac_build_buffer_load_common(
> +			loads[i] = ac_build_llvm7_buffer_load_common(
>   					ctx, rsrc, vindex, tmp,
>   					1 << (load_log_size - 2), glc, slc, can_speculate, false);
>   		}
>   		if (load_log_size >= 2)
>   			loads[i] = ac_to_integer(ctx, loads[i]);
>   	}
>   
>   	if (log_recombine > 0) {
>   		/* Recombine bytes if necessary (GFX6 only) */
>   		LLVMTypeRef dst_type = log_recombine == 2 ? ctx->i32 : ctx->i16;