ac: add basic nir -> llvm type helper
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 10 Nov 2017 02:47:50 +0000 (13:47 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 4 Dec 2017 01:52:18 +0000 (12:52 +1100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_nir_to_llvm.c

index b58bae90c5dc3bf5ba962f3f66d1c9dce7d60928..8610e3671580fd939f575d31dd09b9d121492e91 100644 (file)
@@ -161,6 +161,28 @@ nir_to_llvm_context_from_abi(struct ac_shader_abi *abi)
        return container_of(abi, ctx, abi);
 }
 
+static LLVMTypeRef
+nir2llvmtype(struct ac_nir_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 LLVMValueRef get_sampler_desc(struct ac_nir_context *ctx,
                                     const nir_deref_var *deref,
                                     enum ac_descriptor_type desc_type,