From: Marek Olšák <marek.ol...@amd.com>

---
 src/gallium/drivers/radeonsi/si_shader.c           | 25 +-----------------
 src/gallium/drivers/radeonsi/si_shader_internal.h  |  4 ++-
 .../drivers/radeonsi/si_shader_tgsi_setup.c        | 30 +++++++++++++++++++---
 3 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 0410a32..917e148 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -6278,46 +6278,23 @@ static void si_dump_shader_key(unsigned shader, union 
si_shader_key *key,
 }
 
 static void si_init_shader_ctx(struct si_shader_context *ctx,
                               struct si_screen *sscreen,
                               struct si_shader *shader,
                               LLVMTargetMachineRef tm)
 {
        struct lp_build_tgsi_context *bld_base;
        struct lp_build_tgsi_action tmpl = {};
 
-       memset(ctx, 0, sizeof(*ctx));
-       si_llvm_context_init(
-               ctx, "amdgcn--",
+       si_llvm_context_init(ctx, sscreen, shader, tm,
                (shader && shader->selector) ? &shader->selector->info : NULL,
                (shader && shader->selector) ? shader->selector->tokens : NULL);
-       si_shader_context_init_alu(&ctx->soa.bld_base);
-       ctx->tm = tm;
-       ctx->screen = sscreen;
-       if (shader && shader->selector)
-               ctx->type = shader->selector->info.processor;
-       else
-               ctx->type = -1;
-       ctx->shader = shader;
-
-       ctx->voidt = LLVMVoidTypeInContext(ctx->gallivm.context);
-       ctx->i1 = LLVMInt1TypeInContext(ctx->gallivm.context);
-       ctx->i8 = LLVMInt8TypeInContext(ctx->gallivm.context);
-       ctx->i32 = LLVMInt32TypeInContext(ctx->gallivm.context);
-       ctx->i64 = LLVMInt64TypeInContext(ctx->gallivm.context);
-       ctx->i128 = LLVMIntTypeInContext(ctx->gallivm.context, 128);
-       ctx->f32 = LLVMFloatTypeInContext(ctx->gallivm.context);
-       ctx->v16i8 = LLVMVectorType(ctx->i8, 16);
-       ctx->v2i32 = LLVMVectorType(ctx->i32, 2);
-       ctx->v4i32 = LLVMVectorType(ctx->i32, 4);
-       ctx->v4f32 = LLVMVectorType(ctx->f32, 4);
-       ctx->v8i32 = LLVMVectorType(ctx->i32, 8);
 
        bld_base = &ctx->soa.bld_base;
        bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
 
        bld_base->op_actions[TGSI_OPCODE_INTERP_CENTROID] = interp_action;
        bld_base->op_actions[TGSI_OPCODE_INTERP_SAMPLE] = interp_action;
        bld_base->op_actions[TGSI_OPCODE_INTERP_OFFSET] = interp_action;
 
        bld_base->op_actions[TGSI_OPCODE_TEX] = tex_action;
        bld_base->op_actions[TGSI_OPCODE_TEX2] = tex_action;
diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h 
b/src/gallium/drivers/radeonsi/si_shader_internal.h
index 55b70e6..8d6a40b 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -171,21 +171,23 @@ LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context 
*bld_base,
                          enum tgsi_opcode_type type);
 
 LLVMValueRef bitcast(struct lp_build_tgsi_context *bld_base,
                     enum tgsi_opcode_type type, LLVMValueRef value);
 
 LLVMValueRef si_llvm_bound_index(struct si_shader_context *ctx,
                                 LLVMValueRef index,
                                 unsigned num);
 
 void si_llvm_context_init(struct si_shader_context *ctx,
-                         const char *triple,
+                         struct si_screen *sscreen,
+                         struct si_shader *shader,
+                         LLVMTargetMachineRef tm,
                          const struct tgsi_shader_info *info,
                          const struct tgsi_token *tokens);
 
 void si_llvm_create_func(struct si_shader_context *ctx,
                         const char *name,
                         LLVMTypeRef *return_types, unsigned num_return_elems,
                         LLVMTypeRef *ParamTypes, unsigned ParamCount);
 
 void si_llvm_dispose(struct si_shader_context *ctx);
 
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index b37f7e6..624a167 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -1215,37 +1215,44 @@ static void emit_immediate(struct lp_build_tgsi_context 
*bld_base,
        struct si_shader_context *ctx = si_shader_context(bld_base);
 
        for (i = 0; i < 4; ++i) {
                ctx->soa.immediates[ctx->soa.num_immediates][i] =
                                LLVMConstInt(bld_base->uint_bld.elem_type, 
imm->u[i].Uint, false   );
        }
 
        ctx->soa.num_immediates++;
 }
 
-void si_llvm_context_init(struct si_shader_context *ctx, const char *triple,
+void si_llvm_context_init(struct si_shader_context *ctx,
+                         struct si_screen *sscreen,
+                         struct si_shader *shader,
+                         LLVMTargetMachineRef tm,
                          const struct tgsi_shader_info *info,
                          const struct tgsi_token *tokens)
 {
        struct lp_type type;
 
        /* Initialize the gallivm object:
         * We are only using the module, context, and builder fields of this 
struct.
         * This should be enough for us to be able to pass our gallivm struct 
to the
         * helper functions in the gallivm module.
         */
-       memset(&ctx->gallivm, 0, sizeof (ctx->gallivm));
-       memset(&ctx->soa, 0, sizeof(ctx->soa));
+       memset(ctx, 0, sizeof(*ctx));
+       ctx->shader = shader;
+       ctx->screen = sscreen;
+       ctx->tm = tm;
+       ctx->type = info ? info->processor : -1;
+
        ctx->gallivm.context = LLVMContextCreate();
        ctx->gallivm.module = LLVMModuleCreateWithNameInContext("tgsi",
                                                ctx->gallivm.context);
-       LLVMSetTarget(ctx->gallivm.module, triple);
+       LLVMSetTarget(ctx->gallivm.module, "amdgcn--");
        ctx->gallivm.builder = LLVMCreateBuilderInContext(ctx->gallivm.context);
 
        struct lp_build_tgsi_context *bld_base = &ctx->soa.bld_base;
 
        bld_base->info = info;
 
        if (info && info->array_max[TGSI_FILE_TEMPORARY] > 0) {
                int size = info->array_max[TGSI_FILE_TEMPORARY];
 
                ctx->temp_arrays = CALLOC(size, sizeof(ctx->temp_arrays[0]));
@@ -1294,20 +1301,35 @@ void si_llvm_context_init(struct si_shader_context 
*ctx, const char *triple,
        ctx->soa.outputs = ctx->outputs;
 
        bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit;
        bld_base->op_actions[TGSI_OPCODE_BRK].emit = brk_emit;
        bld_base->op_actions[TGSI_OPCODE_CONT].emit = cont_emit;
        bld_base->op_actions[TGSI_OPCODE_IF].emit = if_emit;
        bld_base->op_actions[TGSI_OPCODE_UIF].emit = uif_emit;
        bld_base->op_actions[TGSI_OPCODE_ELSE].emit = else_emit;
        bld_base->op_actions[TGSI_OPCODE_ENDIF].emit = endif_emit;
        bld_base->op_actions[TGSI_OPCODE_ENDLOOP].emit = endloop_emit;
+
+       si_shader_context_init_alu(&ctx->soa.bld_base);
+
+       ctx->voidt = LLVMVoidTypeInContext(ctx->gallivm.context);
+       ctx->i1 = LLVMInt1TypeInContext(ctx->gallivm.context);
+       ctx->i8 = LLVMInt8TypeInContext(ctx->gallivm.context);
+       ctx->i32 = LLVMInt32TypeInContext(ctx->gallivm.context);
+       ctx->i64 = LLVMInt64TypeInContext(ctx->gallivm.context);
+       ctx->i128 = LLVMIntTypeInContext(ctx->gallivm.context, 128);
+       ctx->f32 = LLVMFloatTypeInContext(ctx->gallivm.context);
+       ctx->v16i8 = LLVMVectorType(ctx->i8, 16);
+       ctx->v2i32 = LLVMVectorType(ctx->i32, 2);
+       ctx->v4i32 = LLVMVectorType(ctx->i32, 4);
+       ctx->v4f32 = LLVMVectorType(ctx->f32, 4);
+       ctx->v8i32 = LLVMVectorType(ctx->i32, 8);
 }
 
 void si_llvm_create_func(struct si_shader_context *ctx,
                         const char *name,
                         LLVMTypeRef *return_types, unsigned num_return_elems,
                         LLVMTypeRef *ParamTypes, unsigned ParamCount)
 {
        LLVMTypeRef main_fn_type, ret_type;
        LLVMBasicBlockRef main_fn_body;
 
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to