From: Roland Scheidegger Date: Thu, 15 May 2014 23:00:53 +0000 (+0200) Subject: gallivm: give more verbose names to modules X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=26cac02c51db0f49f6c67d3cd029ce044a087473;p=mesa.git gallivm: give more verbose names to modules When we had just one module "gallivm" was an appropriate name. But now we have modules containing all functions for a particular variant, so give it a corresponding name (this is really just for helping debugging). Reviewed-by: Brian Paul Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 3624d930f61..d29adfbea3e 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -525,6 +525,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm, struct llvm_vertex_shader *shader = llvm_vertex_shader(llvm->draw->vs.vertex_shader); LLVMTypeRef vertex_header; + char module_name[64]; variant = MALLOC(sizeof *variant + shader->variant_key_size - @@ -535,7 +536,10 @@ draw_llvm_create_variant(struct draw_llvm *llvm, variant->llvm = llvm; variant->shader = shader; - variant->gallivm = gallivm_create(); + util_snprintf(module_name, sizeof(module_name), "draw_llvm_vs_variant%u", + variant->shader->variants_cached); + + variant->gallivm = gallivm_create(module_name); create_jit_types(variant); @@ -1513,8 +1517,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, memset(&system_values, 0, sizeof(system_values)); - util_snprintf(func_name, sizeof(func_name), "draw_llvm_vs_variant%u%s", - variant->shader->variants_cached, elts ? "_elts" : ""); + util_snprintf(func_name, sizeof(func_name), "draw_llvm_vs_variant%u_%s", + variant->shader->variants_cached, elts ? "elts" : "linear"); i = 0; arg_types[i++] = get_context_ptr_type(variant); /* context */ @@ -2177,6 +2181,7 @@ draw_gs_llvm_create_variant(struct draw_llvm *llvm, struct llvm_geometry_shader *shader = llvm_geometry_shader(llvm->draw->gs.geometry_shader); LLVMTypeRef vertex_header; + char module_name[64]; variant = MALLOC(sizeof *variant + shader->variant_key_size - @@ -2187,7 +2192,10 @@ draw_gs_llvm_create_variant(struct draw_llvm *llvm, variant->llvm = llvm; variant->shader = shader; - variant->gallivm = gallivm_create(); + util_snprintf(module_name, sizeof(module_name), "draw_llvm_gs_variant%u", + variant->shader->variants_cached); + + variant->gallivm = gallivm_create(module_name); create_gs_jit_types(variant); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 83ffad9a838..7aebebb12d3 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -284,7 +284,7 @@ fail: * \return TRUE for success, FALSE for failure */ static boolean -init_gallivm_state(struct gallivm_state *gallivm) +init_gallivm_state(struct gallivm_state *gallivm, const char *name) { assert(!gallivm->context); assert(!gallivm->module); @@ -299,7 +299,7 @@ init_gallivm_state(struct gallivm_state *gallivm) if (!gallivm->context) goto fail; - gallivm->module = LLVMModuleCreateWithNameInContext("gallivm", + gallivm->module = LLVMModuleCreateWithNameInContext(name, gallivm->context); if (!gallivm->module) goto fail; @@ -466,16 +466,15 @@ lp_build_init(void) /** * Create a new gallivm_state object. - * Note that we return a singleton. */ struct gallivm_state * -gallivm_create(void) +gallivm_create(const char *name) { struct gallivm_state *gallivm; gallivm = CALLOC_STRUCT(gallivm_state); if (gallivm) { - if (!init_gallivm_state(gallivm)) { + if (!init_gallivm_state(gallivm, name)) { FREE(gallivm); gallivm = NULL; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h index 464bb832929..2e32cf8b077 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -54,7 +54,7 @@ lp_build_init(void); struct gallivm_state * -gallivm_create(void); +gallivm_create(const char *name); void gallivm_destroy(struct gallivm_state *gallivm); diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 655891cffb1..4872e0d1a30 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -2160,7 +2160,7 @@ generate_fragment(struct llvmpipe_context *lp, struct gallivm_state *gallivm = variant->gallivm; const struct lp_fragment_shader_variant_key *key = &variant->key; struct lp_shader_input inputs[PIPE_MAX_SHADER_INPUTS]; - char func_name[256]; + char func_name[64]; struct lp_type fs_type; struct lp_type blend_type; LLVMTypeRef fs_elem_type; @@ -2247,8 +2247,8 @@ generate_fragment(struct llvmpipe_context *lp, blend_vec_type = lp_build_vec_type(gallivm, blend_type); - util_snprintf(func_name, sizeof(func_name), "fs%u_variant%u_%s", - shader->no, variant->no, partial_mask ? "partial" : "whole"); + util_snprintf(func_name, sizeof(func_name), "fs%u_variant%u_%s", + shader->no, variant->no, partial_mask ? "partial" : "whole"); arg_types[0] = variant->jit_context_ptr_type; /* context */ arg_types[1] = int32_type; /* x */ @@ -2558,12 +2558,16 @@ generate_variant(struct llvmpipe_context *lp, struct lp_fragment_shader_variant *variant; const struct util_format_description *cbuf0_format_desc; boolean fullcolormask; + char module_name[64]; variant = CALLOC_STRUCT(lp_fragment_shader_variant); if(!variant) return NULL; - variant->gallivm = gallivm_create(); + util_snprintf(module_name, sizeof(module_name), "fs%u_variant%u", + shader->no, shader->variants_created); + + variant->gallivm = gallivm_create(module_name); if (!variant->gallivm) { FREE(variant); return NULL; diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c index 361ee70b662..63c92d588c9 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c @@ -711,7 +711,7 @@ generate_setup_variant(struct lp_setup_variant_key *key, struct lp_setup_variant *variant = NULL; struct gallivm_state *gallivm; struct lp_setup_args args; - char func_name[256]; + char func_name[64]; LLVMTypeRef vec4f_type; LLVMTypeRef func_type; LLVMTypeRef arg_types[7]; @@ -726,13 +726,17 @@ generate_setup_variant(struct lp_setup_variant_key *key, if (variant == NULL) goto fail; - variant->gallivm = gallivm = gallivm_create(); + variant->no = setup_no++; + + util_snprintf(func_name, sizeof(func_name), "setup_variant_%u", + variant->no); + + variant->gallivm = gallivm = gallivm_create(func_name); if (!variant->gallivm) { goto fail; } builder = gallivm->builder; - variant->no = setup_no++; if (LP_DEBUG & DEBUG_COUNTERS) { t0 = os_time_get(); @@ -741,9 +745,6 @@ generate_setup_variant(struct lp_setup_variant_key *key, memcpy(&variant->key, key, key->size); variant->list_item_global.base = variant; - util_snprintf(func_name, sizeof(func_name), "setup_variant_%u", - variant->no); - /* Currently always deal with full 4-wide vertex attributes from * the vertices. */ diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c index f8998c159fb..bf405a54ae1 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c @@ -354,7 +354,7 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test) in[i] = 1.0; } - gallivm = gallivm_create(); + gallivm = gallivm_create("test_module"); test_func = build_unary_test_func(gallivm, test); diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c index ec80593baf6..4775aff877b 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c @@ -450,7 +450,7 @@ test_one(unsigned verbose, if(verbose >= 1) dump_blend_type(stdout, blend, type); - gallivm = gallivm_create(); + gallivm = gallivm_create("test_module"); func = add_blend_test(gallivm, blend, type); diff --git a/src/gallium/drivers/llvmpipe/lp_test_conv.c b/src/gallium/drivers/llvmpipe/lp_test_conv.c index b7d0bfda4b8..948a218d7f7 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_conv.c +++ b/src/gallium/drivers/llvmpipe/lp_test_conv.c @@ -211,7 +211,7 @@ test_one(unsigned verbose, eps = MAX2(lp_const_eps(src_type), lp_const_eps(dst_type)); - gallivm = gallivm_create(); + gallivm = gallivm_create("test_module"); func = add_conv_test(gallivm, src_type, num_srcs, dst_type, num_dsts); diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index d27e1b1c7de..2c8321939ae 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -138,7 +138,7 @@ test_format_float(unsigned verbose, FILE *fp, boolean success = TRUE; unsigned i, j, k, l; - gallivm = gallivm_create(); + gallivm = gallivm_create("test_module_float"); fetch = add_fetch_rgba_test(gallivm, verbose, desc, lp_float32_vec4_type()); @@ -223,7 +223,7 @@ test_format_unorm8(unsigned verbose, FILE *fp, boolean success = TRUE; unsigned i, j, k, l; - gallivm = gallivm_create(); + gallivm = gallivm_create("test_module_unorm8"); fetch = add_fetch_rgba_test(gallivm, verbose, desc, lp_unorm8_vec4_type()); diff --git a/src/gallium/drivers/llvmpipe/lp_test_printf.c b/src/gallium/drivers/llvmpipe/lp_test_printf.c index 37c1b559e8b..4b74ae96a7a 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_printf.c +++ b/src/gallium/drivers/llvmpipe/lp_test_printf.c @@ -94,7 +94,7 @@ test_printf(unsigned verbose, FILE *fp, test_printf_t test_printf_func; boolean success = TRUE; - gallivm = gallivm_create(); + gallivm = gallivm_create("test_module"); test = add_printf_test(gallivm);