[Mesa-dev] [PATCH 15/20] radeonsi: add basic nir -> llvm type helper

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


---
 src/gallium/drivers/radeonsi/si_shader_nir.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 847d75ba14..fca16f46cf 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -25,20 +25,42 @@
 #include "si_shader_internal.h"
 
 #include "ac_nir_to_llvm.h"
 
 #include "tgsi/tgsi_from_mesa.h"
 
 #include "compiler/nir/nir.h"
 #include "compiler/nir_types.h"
 
 
+static LLVMTypeRef
+nir2llvmtype(struct si_shader_context *ctx,
+	     const struct glsl_type *type)
+{
+	switch (glsl_get_base_type(glsl_without_array(type))) {
+	case GLSL_TYPE_UINT:
+	case GLSL_TYPE_INT:
+		return ctx->ac.i32;
+	case GLSL_TYPE_UINT64:
+	case GLSL_TYPE_INT64:
+		return ctx->ac.i64;
+	case GLSL_TYPE_DOUBLE:
+		return ctx->ac.f64;
+	case GLSL_TYPE_FLOAT:
+		return ctx->ac.f32;
+	default:
+		assert(!"Unsupported type in nir2llvmtype()");
+		break;
+	}
+	return 0;
+}
+
 static int
 type_size(const struct glsl_type *type)
 {
    return glsl_count_attribute_slots(type, false);
 }
 
 static void scan_instruction(struct tgsi_shader_info *info,
 			     nir_instr *instr)
 {
 	if (instr->type == nir_instr_type_alu) {
-- 
2.14.3



More information about the mesa-dev mailing list