ac: create the LLVM builder in ac_llvm_context_init
authorMarek Olšák <marek.olsak@amd.com>
Fri, 12 Jul 2019 21:35:39 +0000 (17:35 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 20 Jul 2019 00:16:19 +0000 (20:16 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/amd/vulkan/radv_nir_to_llvm.c
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index 4465acbd0ad808884a7ba0fc03fdf82ddd6628e9..855ebb3d3dd6d2813e22587083c7ed208c83afa4 100644 (file)
@@ -60,7 +60,7 @@ void
 ac_llvm_context_init(struct ac_llvm_context *ctx,
                     struct ac_llvm_compiler *compiler,
                     enum chip_class chip_class, enum radeon_family family,
-                    unsigned wave_size)
+                    enum ac_float_mode float_mode, unsigned wave_size)
 {
        LLVMValueRef args[1];
 
@@ -72,7 +72,7 @@ ac_llvm_context_init(struct ac_llvm_context *ctx,
        ctx->module = ac_create_module(wave_size == 32 ? compiler->tm_wave32
                                                       : compiler->tm,
                                       ctx->context);
-       ctx->builder = NULL;
+       ctx->builder = ac_create_builder(ctx->context, float_mode);
 
        ctx->voidt = LLVMVoidTypeInContext(ctx->context);
        ctx->i1 = LLVMInt1TypeInContext(ctx->context);
index 9efd755b90be1d21c7d7573f189bf3e0bf6f0311..cc1807221b212ed1c89a5a7287a0bc4d116850fa 100644 (file)
@@ -49,6 +49,7 @@ enum {
 
 struct ac_llvm_flow;
 struct ac_llvm_compiler;
+enum ac_float_mode;
 
 struct ac_llvm_context {
        LLVMContextRef context;
@@ -113,7 +114,7 @@ void
 ac_llvm_context_init(struct ac_llvm_context *ctx,
                     struct ac_llvm_compiler *compiler,
                     enum chip_class chip_class, enum radeon_family family,
-                    unsigned wave_size);
+                    enum ac_float_mode float_mode, unsigned wave_size);
 
 void
 ac_llvm_context_dispose(struct ac_llvm_context *ctx);
index 0c739e1ebd9a0815405cda067a3ef6832ad25db8..27b46d2e1bad75825bb909fed0af9e9c00f8e7a6 100644 (file)
@@ -4319,14 +4319,13 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
        ctx.options = options;
        ctx.shader_info = shader_info;
 
-       ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class, options->family, 64);
-       ctx.context = ctx.ac.context;
-
        enum ac_float_mode float_mode =
                options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
                                       AC_FLOAT_MODE_DEFAULT;
 
-       ctx.ac.builder = ac_create_builder(ctx.context, float_mode);
+       ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class,
+                            options->family, float_mode, 64);
+       ctx.context = ctx.ac.context;
 
        radv_nir_shader_info_init(&shader_info->info);
 
@@ -4837,16 +4836,15 @@ radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
        ctx.options = options;
        ctx.shader_info = shader_info;
 
-       ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class, options->family, 64);
-       ctx.context = ctx.ac.context;
-
-       ctx.is_gs_copy_shader = true;
-
        enum ac_float_mode float_mode =
                options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
                                       AC_FLOAT_MODE_DEFAULT;
 
-       ctx.ac.builder = ac_create_builder(ctx.context, float_mode);
+       ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class,
+                            options->family, float_mode, 64);
+       ctx.context = ctx.ac.context;
+
+       ctx.is_gs_copy_shader = true;
        ctx.stage = MESA_SHADER_VERTEX;
 
        radv_nir_shader_info_pass(geom_shader, options, &shader_info->info);
index 3de720c27b8541f707a1a31780194fcf1d795b99..c534a445db4b2ba9c09e82131eaf2c7d929a5453 100644 (file)
@@ -962,14 +962,13 @@ void si_llvm_context_init(struct si_shader_context *ctx,
        ctx->screen = sscreen;
        ctx->compiler = compiler;
 
-       ac_llvm_context_init(&ctx->ac, compiler, sscreen->info.chip_class,
-                            sscreen->info.family, 64);
-
        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;
-       ctx->ac.builder = ac_create_builder(ctx->ac.context, float_mode);
+
+       ac_llvm_context_init(&ctx->ac, compiler, sscreen->info.chip_class,
+                            sscreen->info.family, float_mode, 64);
 
        ctx->gallivm.context = ctx->ac.context;
        ctx->gallivm.module = ctx->ac.module;