[Mesa-dev] [PATCH 10/20] radeonsi: introduce bitcast_llvmtype()

Timothy Arceri tarceri at itsqueeze.com
Fri Nov 10 03:13:44 UTC 2017


This is like bitcast() but takes an llvm type rather than a tgsi
type.
---
 src/gallium/drivers/radeonsi/si_shader_internal.h   | 3 +++
 src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h
index 7ff8815b92..4da39830f6 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -242,20 +242,23 @@ si_shader_context_from_abi(struct ac_shader_abi *abi)
 
 void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
 
 unsigned si_llvm_compile(LLVMModuleRef M, struct ac_shader_binary *binary,
 			 LLVMTargetMachineRef tm,
 			 struct pipe_debug_callback *debug);
 
 LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context *bld_base,
 			  enum tgsi_opcode_type type);
 
+LLVMValueRef bitcast_llvmtype(struct si_shader_context *ctx,
+			      LLVMTypeRef type, LLVMValueRef value);
+
 LLVMValueRef bitcast(struct lp_build_tgsi_context *bld_base,
 		     enum tgsi_opcode_type type, LLVMValueRef value);
 
 LLVMValueRef si_llvm_bound_index(struct si_shader_context *ctx,
 				 LLVMValueRef index,
 				 unsigned num);
 
 void si_llvm_context_init(struct si_shader_context *ctx,
 			  struct si_screen *sscreen,
 			  LLVMTargetMachineRef tm);
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index 59d02605e9..b6a919fc8f 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -177,20 +177,29 @@ LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context *bld_base,
 	case TGSI_TYPE_DOUBLE:
 		return ctx->ac.f64;
 	case TGSI_TYPE_UNTYPED:
 	case TGSI_TYPE_FLOAT:
 		return ctx->ac.f32;
 	default: break;
 	}
 	return 0;
 }
 
+LLVMValueRef bitcast_llvmtype(struct si_shader_context *ctx,
+			      LLVMTypeRef type, LLVMValueRef value)
+{
+	if (type)
+		return LLVMBuildBitCast(ctx->ac.builder, value, type, "");
+	else
+		return value;
+}
+
 LLVMValueRef bitcast(struct lp_build_tgsi_context *bld_base,
 		     enum tgsi_opcode_type type, LLVMValueRef value)
 {
 	struct si_shader_context *ctx = si_shader_context(bld_base);
 	LLVMTypeRef dst_type = tgsi2llvmtype(bld_base, type);
 
 	if (dst_type)
 		return LLVMBuildBitCast(ctx->ac.builder, value, dst_type, "");
 	else
 		return value;
-- 
2.14.3



More information about the mesa-dev mailing list