[Mesa-dev] [PATCH 1/4] radeonsi: move LLVMTargetMachineRef creation to a separate function

Marek Olšák maraeo at gmail.com
Wed Jun 29 16:32:54 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeonsi/si_pipe.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 633d4bb..2e8d846 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -103,14 +103,29 @@ si_amdgpu_get_reset_status(struct pipe_context *ctx)
 	return sctx->b.ws->ctx_query_reset_status(sctx->b.ctx);
 }
 
+static LLVMTargetMachineRef
+si_create_llvm_target_machine(struct si_screen *sscreen)
+{
+	const char *triple = "amdgcn--";
+
+	return LLVMCreateTargetMachine(radeon_llvm_get_r600_target(triple), triple,
+				       r600_get_llvm_processor_name(sscreen->b.family),
+#if HAVE_LLVM >= 0x0308
+				       sscreen->b.debug_flags & DBG_SI_SCHED ?
+					       SI_LLVM_DEFAULT_FEATURES ",+si-scheduler" :
+#endif
+					       SI_LLVM_DEFAULT_FEATURES,
+				       LLVMCodeGenLevelDefault,
+				       LLVMRelocDefault,
+				       LLVMCodeModelDefault);
+}
+
 static struct pipe_context *si_create_context(struct pipe_screen *screen,
                                               void *priv, unsigned flags)
 {
 	struct si_context *sctx = CALLOC_STRUCT(si_context);
 	struct si_screen* sscreen = (struct si_screen *)screen;
 	struct radeon_winsys *ws = sscreen->b.ws;
-	LLVMTargetRef r600_target;
-	const char *triple = "amdgcn--";
 	int shader, i;
 
 	if (!sctx)
@@ -255,18 +270,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
 	sctx->scratch_waves = MAX2(32 * sscreen->b.info.num_good_compute_units,
 				   max_threads_per_block / 64);
 
-	/* Initialize LLVM TargetMachine */
-	r600_target = radeon_llvm_get_r600_target(triple);
-	sctx->tm = LLVMCreateTargetMachine(r600_target, triple,
-					   r600_get_llvm_processor_name(sscreen->b.family),
-#if HAVE_LLVM >= 0x0308
-					   sscreen->b.debug_flags & DBG_SI_SCHED ?
-						SI_LLVM_DEFAULT_FEATURES ",+si-scheduler" :
-#endif
-						SI_LLVM_DEFAULT_FEATURES,
-					   LLVMCodeGenLevelDefault,
-					   LLVMRelocDefault,
-					   LLVMCodeModelDefault);
+	sctx->tm = si_create_llvm_target_machine(sscreen);
 
 	return &sctx->b.b;
 fail:
-- 
2.7.4



More information about the mesa-dev mailing list