ac: fold LLVMContext creation into ac_llvm_context_init
authorMarek Olšák <marek.olsak@amd.com>
Wed, 4 Jul 2018 05:37:30 +0000 (01:37 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 4 Jul 2018 19:48:18 +0000 (15:48 -0400)
Reviewed-by: Dave Airlie <airlied@redhat.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 93ae273f900bb436594ff042ca71ac017326c5e2..a77c29270d1960102c3465e8271bcd96b4d2a2d0 100644 (file)
@@ -57,15 +57,15 @@ struct ac_llvm_flow {
  * The caller is responsible for initializing ctx::module and ctx::builder.
  */
 void
-ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context,
+ac_llvm_context_init(struct ac_llvm_context *ctx,
                     enum chip_class chip_class, enum radeon_family family)
 {
        LLVMValueRef args[1];
 
+       ctx->context = LLVMContextCreate();
+
        ctx->chip_class = chip_class;
        ctx->family = family;
-
-       ctx->context = context;
        ctx->module = NULL;
        ctx->builder = NULL;
 
index 026955a5556b591c8775735f49ff2a16b85b2d78..4e7cbcd5fa0f44c13da04b282dc2cfc11f7b0e10 100644 (file)
@@ -97,7 +97,7 @@ struct ac_llvm_context {
 };
 
 void
-ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context,
+ac_llvm_context_init(struct ac_llvm_context *ctx,
                     enum chip_class chip_class, enum radeon_family family);
 
 void
index 45ac0854c17a74f3e6d7775b30d54d562c18ae8e..15c1049302282d750f72b7be6b53114a5b153864 100644 (file)
@@ -3137,10 +3137,9 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
        unsigned i;
        ctx.options = options;
        ctx.shader_info = shader_info;
-       ctx.context = LLVMContextCreate();
 
-       ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
-                            options->family);
+       ac_llvm_context_init(&ctx.ac, options->chip_class, options->family);
+       ctx.context = ctx.ac.context;
        ctx.ac.module = ac_create_module(ac_llvm->tm, ctx.context);
 
        enum ac_float_mode float_mode =
@@ -3576,12 +3575,11 @@ radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
                            const struct radv_nir_compiler_options *options)
 {
        struct radv_shader_context ctx = {0};
-       ctx.context = LLVMContextCreate();
        ctx.options = options;
        ctx.shader_info = shader_info;
 
-       ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
-                            options->family);
+       ac_llvm_context_init(&ctx.ac, options->chip_class, options->family);
+       ctx.context = ctx.ac.context;
        ctx.ac.module = ac_create_module(ac_llvm->tm, ctx.context);
 
        ctx.is_gs_copy_shader = true;
index b8cfd15a67f8fbd7cd4baa8bfb21d923ad2c76d2..b486be257495d862763c63230086ef784866fdb4 100644 (file)
@@ -956,10 +956,7 @@ void si_llvm_context_init(struct si_shader_context *ctx,
        ctx->screen = sscreen;
        ctx->compiler = compiler;
 
-       ctx->ac.context = LLVMContextCreate();
-       ac_llvm_context_init(&ctx->ac, ctx->ac.context,
-                            sscreen->info.chip_class, sscreen->info.family);
-
+       ac_llvm_context_init(&ctx->ac, sscreen->info.chip_class, sscreen->info.family);
        ctx->ac.module = ac_create_module(compiler->tm, ctx->ac.context);
 
        enum ac_float_mode float_mode =