[Mesa-dev] [PATCH 18/18] gallium/radeon: add a function for adding llvm function attributes

Marek Olšák maraeo at gmail.com
Fri Feb 5 19:20:44 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

This will be used for setting the new InitialPSInputAddr attribute.
---
 src/gallium/drivers/radeon/radeon_llvm_emit.c | 13 +++++++++----
 src/gallium/drivers/radeon/radeon_llvm_emit.h |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c b/src/gallium/drivers/radeon/radeon_llvm_emit.c
index 3d09876..474154e 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c
@@ -55,6 +55,14 @@ enum radeon_llvm_shader_type {
 	RADEON_LLVM_SHADER_CS = 3,
 };
 
+void radeon_llvm_add_attribute(LLVMValueRef F, const char *name, int value)
+{
+	char str[16];
+
+	snprintf(str, sizeof(str), "%i", value);
+	LLVMAddTargetDependentFunctionAttr(F, name, str);
+}
+
 /**
  * Set the shader type we want to compile
  *
@@ -62,7 +70,6 @@ enum radeon_llvm_shader_type {
  */
 void radeon_llvm_shader_type(LLVMValueRef F, unsigned type)
 {
-	char Str[2];
 	enum radeon_llvm_shader_type llvm_type;
 
 	switch (type) {
@@ -84,9 +91,7 @@ void radeon_llvm_shader_type(LLVMValueRef F, unsigned type)
 		assert(0);
 	}
 
-	sprintf(Str, "%1d", llvm_type);
-
-	LLVMAddTargetDependentFunctionAttr(F, "ShaderType", Str);
+	radeon_llvm_add_attribute(F, "ShaderType", llvm_type);
 }
 
 static void init_r600_target()
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.h b/src/gallium/drivers/radeon/radeon_llvm_emit.h
index 45f05a9..84dbd25 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.h
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.h
@@ -34,6 +34,7 @@
 struct pipe_debug_callback;
 struct radeon_shader_binary;
 
+void radeon_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
 void radeon_llvm_shader_type(LLVMValueRef F, unsigned type);
 
 LLVMTargetRef radeon_llvm_get_r600_target(const char *triple);
-- 
2.1.4



More information about the mesa-dev mailing list