util: remove LIST_IS_EMPTY macro
[mesa.git] / src / gallium / drivers / radeonsi / si_shader_tgsi_setup.c
index c534a445db4b2ba9c09e82131eaf2c7d929a5453..1c6522322ff643c5271216db0f5af6d166d36947 100644 (file)
@@ -83,11 +83,15 @@ static void si_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context)
 unsigned si_llvm_compile(LLVMModuleRef M, struct si_shader_binary *binary,
                         struct ac_llvm_compiler *compiler,
                         struct pipe_debug_callback *debug,
-                        bool less_optimized)
+                        bool less_optimized, unsigned wave_size)
 {
-       struct ac_compiler_passes *passes =
-               less_optimized && compiler->low_opt_passes ?
-                       compiler->low_opt_passes : compiler->passes;
+       struct ac_compiler_passes *passes = compiler->passes;
+
+       if (wave_size == 32)
+               passes = compiler->passes_wave32;
+       else if (less_optimized && compiler->low_opt_passes)
+               passes = compiler->low_opt_passes;
+
        struct si_llvm_diagnostics diag;
        LLVMContextRef llvm_ctx;
 
@@ -949,7 +953,9 @@ static void emit_immediate(struct lp_build_tgsi_context *bld_base,
 
 void si_llvm_context_init(struct si_shader_context *ctx,
                          struct si_screen *sscreen,
-                         struct ac_llvm_compiler *compiler)
+                         struct ac_llvm_compiler *compiler,
+                         unsigned wave_size,
+                         unsigned ballot_mask_bits)
 {
        struct lp_type type;
 
@@ -962,13 +968,10 @@ void si_llvm_context_init(struct si_shader_context *ctx,
        ctx->screen = sscreen;
        ctx->compiler = compiler;
 
-       enum ac_float_mode float_mode =
-               sscreen->debug_flags & DBG(UNSAFE_MATH) ?
-                       AC_FLOAT_MODE_UNSAFE_FP_MATH :
-                       AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH;
-
        ac_llvm_context_init(&ctx->ac, compiler, sscreen->info.chip_class,
-                            sscreen->info.family, float_mode, 64);
+                            sscreen->info.family,
+                            AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH,
+                            wave_size, ballot_mask_bits);
 
        ctx->gallivm.context = ctx->ac.context;
        ctx->gallivm.module = ctx->ac.module;
@@ -1005,7 +1008,7 @@ void si_llvm_context_init(struct si_shader_context *ctx,
        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->bld_base);
+       si_shader_context_init_alu(ctx);
        si_shader_context_init_mem(ctx);
 
        ctx->voidt = LLVMVoidTypeInContext(ctx->ac.context);
@@ -1028,19 +1031,14 @@ void si_llvm_context_init(struct si_shader_context *ctx,
 
 /* Set the context to a certain TGSI shader. Can be called repeatedly
  * to change the shader. */
-void si_llvm_context_set_tgsi(struct si_shader_context *ctx,
-                             struct si_shader *shader)
+void si_llvm_context_set_ir(struct si_shader_context *ctx,
+                           struct si_shader *shader)
 {
-       const struct tgsi_shader_info *info = NULL;
-       const struct tgsi_token *tokens = NULL;
-
-       if (shader && shader->selector) {
-               info = &shader->selector->info;
-               tokens = shader->selector->tokens;
-       }
+       struct si_shader_selector *sel = shader->selector;
+       const struct tgsi_shader_info *info = &sel->info;
 
        ctx->shader = shader;
-       ctx->type = info ? info->processor : -1;
+       ctx->type = sel->type;
        ctx->bld_base.info = info;
 
        /* Clean up the old contents. */
@@ -1057,16 +1055,13 @@ void si_llvm_context_set_tgsi(struct si_shader_context *ctx,
        ctx->temps = NULL;
        ctx->temps_count = 0;
 
-       if (!info)
-               return;
-
        ctx->num_const_buffers = util_last_bit(info->const_buffers_declared);
        ctx->num_shader_buffers = util_last_bit(info->shader_buffers_declared);
 
        ctx->num_samplers = util_last_bit(info->samplers_declared);
        ctx->num_images = util_last_bit(info->images_declared);
 
-       if (!tokens)
+       if (sel->nir)
                return;
 
        if (info->array_max[TGSI_FILE_TEMPORARY] > 0) {
@@ -1075,7 +1070,7 @@ void si_llvm_context_set_tgsi(struct si_shader_context *ctx,
                ctx->temp_arrays = CALLOC(size, sizeof(ctx->temp_arrays[0]));
                ctx->temp_array_allocas = CALLOC(size, sizeof(ctx->temp_array_allocas[0]));
 
-               tgsi_scan_arrays(tokens, TGSI_FILE_TEMPORARY, size,
+               tgsi_scan_arrays(sel->tokens, TGSI_FILE_TEMPORARY, size,
                                 ctx->temp_arrays);
        }
        if (info->file_max[TGSI_FILE_IMMEDIATE] >= 0) {