[Mesa-dev] [PATCH 17/18] ac/nir: remove nir_to_llvm_context::module

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Feb 9 12:54:34 UTC 2018


Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/common/ac_nir_to_llvm.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index ae9e7b6c80..70718853ec 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -79,7 +79,6 @@ struct nir_to_llvm_context {
 
 	unsigned max_workgroup_size;
 	LLVMContextRef context;
-	LLVMModuleRef module;
 	LLVMValueRef main_function;
 
 	LLVMValueRef descriptor_sets[AC_UD_MAX_SETS];
@@ -1020,7 +1019,7 @@ static void create_function(struct nir_to_llvm_context *ctx,
 	}
 
 	ctx->main_function = create_llvm_function(
-	    ctx->context, ctx->module, ctx->ac.builder, NULL, 0, &args,
+	    ctx->context, ctx->ac.module, ctx->ac.builder, NULL, 0, &args,
 	    ctx->max_workgroup_size,
 	    ctx->options->unsafe_math);
 	set_llvm_calling_convention(ctx->main_function, stage);
@@ -6537,7 +6536,7 @@ static void ac_llvm_finalize_module(struct nir_to_llvm_context * ctx)
 	LLVMPassManagerRef passmgr;
 	/* Create the pass manager */
 	passmgr = LLVMCreateFunctionPassManagerForModule(
-							ctx->module);
+							ctx->ac.module);
 
 	/* This pass should eliminate all the load and store instructions */
 	LLVMAddPromoteMemoryToRegisterPass(passmgr);
@@ -6732,16 +6731,15 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
 	ctx.options = options;
 	ctx.shader_info = shader_info;
 	ctx.context = LLVMContextCreate();
-	ctx.module = LLVMModuleCreateWithNameInContext("shader", ctx.context);
 
 	ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
 			     options->family);
-	ctx.ac.module = ctx.module;
-	LLVMSetTarget(ctx.module, options->supports_spill ? "amdgcn-mesa-mesa3d" : "amdgcn--");
+	ctx.ac.module = LLVMModuleCreateWithNameInContext("shader", ctx.context);
+	LLVMSetTarget(ctx.ac.module, options->supports_spill ? "amdgcn-mesa-mesa3d" : "amdgcn--");
 
 	LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm);
 	char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
-	LLVMSetDataLayout(ctx.module, data_layout_str);
+	LLVMSetDataLayout(ctx.ac.module, data_layout_str);
 	LLVMDisposeTargetData(data_layout);
 	LLVMDisposeMessage(data_layout_str);
 
@@ -6883,14 +6881,14 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
 	LLVMBuildRetVoid(ctx.ac.builder);
 
 	if (options->dump_preoptir)
-		ac_dump_module(ctx.module);
+		ac_dump_module(ctx.ac.module);
 
 	ac_llvm_finalize_module(&ctx);
 
 	if (shader_count == 1)
 		ac_nir_eliminate_const_vs_outputs(&ctx);
 
-	return ctx.module;
+	return ctx.ac.module;
 }
 
 static void ac_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context)
@@ -7150,16 +7148,15 @@ void ac_create_gs_copy_shader(LLVMTargetMachineRef tm,
 {
 	struct nir_to_llvm_context ctx = {0};
 	ctx.context = LLVMContextCreate();
-	ctx.module = LLVMModuleCreateWithNameInContext("shader", ctx.context);
 	ctx.options = options;
 	ctx.shader_info = shader_info;
 
 	ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class,
 			     options->family);
-	ctx.ac.module = ctx.module;
+	ctx.ac.module = LLVMModuleCreateWithNameInContext("shader", ctx.context);
 
 	ctx.is_gs_copy_shader = true;
-	LLVMSetTarget(ctx.module, "amdgcn--");
+	LLVMSetTarget(ctx.ac.module, "amdgcn--");
 
 	enum ac_float_mode float_mode =
 		options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
@@ -7196,7 +7193,7 @@ void ac_create_gs_copy_shader(LLVMTargetMachineRef tm,
 
 	ac_llvm_finalize_module(&ctx);
 
-	ac_compile_llvm_module(tm, ctx.module, binary, config, shader_info,
+	ac_compile_llvm_module(tm, ctx.ac.module, binary, config, shader_info,
 			       MESA_SHADER_VERTEX,
 			       dump_shader, options->supports_spill);
 }
-- 
2.16.1



More information about the mesa-dev mailing list