[Mesa-dev] [PATCH 1/2] ac: create ac_get_zero_for_type() helper

Timothy Arceri tarceri at itsqueeze.com
Mon Feb 26 05:14:25 UTC 2018


---
 src/amd/common/ac_llvm_build.c | 15 +++++++++++++++
 src/amd/common/ac_llvm_build.h |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 15144addb9..f3775938e5 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -148,6 +148,21 @@ ac_get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type)
 	unreachable("Unhandled type kind in get_elem_bits");
 }
 
+LLVMValueRef
+ac_get_zero_for_type(struct ac_llvm_context *ctx, LLVMTypeRef type)
+{
+	if (type == ctx->i32)
+		return ctx->i32_0;
+	if (type == ctx->f32)
+		return ctx->f32_0;
+	if (type == ctx->i64)
+		return ctx->i64_0;
+	if (type == ctx->f64)
+		return ctx->f64_0;
+
+	unreachable("Unhandled type kind in ac_get_zero_for_type()");
+}
+
 unsigned
 ac_get_type_size(LLVMTypeRef type)
 {
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 0a49ad8ca1..2051dc35bc 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -100,6 +100,9 @@ ac_get_llvm_num_components(LLVMValueRef value);
 int
 ac_get_elem_bits(struct ac_llvm_context *ctx, LLVMTypeRef type);
 
+LLVMValueRef
+ac_get_zero_for_type(struct ac_llvm_context *ctx, LLVMTypeRef type);
+
 LLVMValueRef
 ac_llvm_extract_elem(struct ac_llvm_context *ac,
 		     LLVMValueRef value,
-- 
2.14.3



More information about the mesa-dev mailing list