gallivm: give more verbose names to modules
authorRoland Scheidegger <sroland@vmware.com>
Thu, 15 May 2014 23:00:53 +0000 (01:00 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Fri, 16 May 2014 20:50:14 +0000 (22:50 +0200)
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 <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/gallivm/lp_bld_init.c
src/gallium/auxiliary/gallivm/lp_bld_init.h
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_setup.c
src/gallium/drivers/llvmpipe/lp_test_arit.c
src/gallium/drivers/llvmpipe/lp_test_blend.c
src/gallium/drivers/llvmpipe/lp_test_conv.c
src/gallium/drivers/llvmpipe/lp_test_format.c
src/gallium/drivers/llvmpipe/lp_test_printf.c

index 3624d930f61fabc2c4fe40406cb427d8297e0746..d29adfbea3ec18a01a1a24d84ec008465b9796da 100644 (file)
@@ -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);
 
index 83ffad9a838499ba9404fd41df3fc1e92566a3aa..7aebebb12d3dbd949749acedb22c51e090a27209 100644 (file)
@@ -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;
       }
index 464bb8329298c493750ad45ae0f0bcb95908f6f1..2e32cf8b077f4eca49b34a84880a7cbdcc7d4366 100644 (file)
@@ -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);
index 655891cffb16d51cb72842992d58c7380a958302..4872e0d1a303dba076e484389c3187a0a1069cd4 100644 (file)
@@ -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;
index 361ee70b6629b8e1c0321718bcdba654c7f6e946..63c92d588c96db742dfda97a7a11bec283a98f72 100644 (file)
@@ -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.
     */
index f8998c159fbca9b30786a44cdfbc4577262ce10d..bf405a54ae10b6eac9577543b6cd7a1f9124c830 100644 (file)
@@ -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);
 
index ec80593baf6d5b6d81c15425fa6705b4c1d525d2..4775aff877bdcd859229c1606063515a66af6248 100644 (file)
@@ -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);
 
index b7d0bfda4b81c99372cdb332c9676c5258917278..948a218d7f73f1eb4e88277046aa3c710d0dd784 100644 (file)
@@ -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);
 
index d27e1b1c7defd245f3673eef161c7fb614a9bd19..2c8321939ae174c6fd03cb3700bbb0ac78670cff 100644 (file)
@@ -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());
 
index 37c1b559e8b899b1597870e587155733b0ae39a9..4b74ae96a7a87d257e9e7b25b247503e1502a637 100644 (file)
@@ -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);