diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2014-10-15 12:24:30 -0400 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2015-01-06 12:53:21 -0800 |
commit | 761e36b4caab4e8e09a4c2b1409a825902fc7d2c (patch) | |
tree | c8b8639b11190ebfcc43f4e22fa771f86d551bd8 /src/gallium/drivers/radeonsi | |
parent | 934e41c0b31cffa4efc08f61cff2389e3149b3f3 (diff) |
radeonsi: Cache LLVMTargetMachine object in si_screen
Rather than building a new one every compile. This should reduce some
of the overhead of compiling shaders.
One consequence of this change is that we lose the MachineInstrs dumps
when dumping the shaders via R600_DEBUG. The LLVM IR and assembly is
still dumped, and if you still want to see the MachineInstr dump, you
can run the dumped LLVM IR through llc.
Diffstat (limited to 'src/gallium/drivers/radeonsi')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index afb6364a776..4b7156140b7 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -25,10 +25,14 @@ #include "si_public.h" #include "sid.h" +#include "radeon/radeon_llvm_emit.h" #include "radeon/radeon_uvd.h" #include "util/u_memory.h" #include "vl/vl_decoder.h" +#include <llvm-c/Target.h> +#include <llvm-c/TargetMachine.h> + /* * pipe_context */ @@ -420,6 +424,10 @@ static void si_destroy_screen(struct pipe_screen* pscreen) return; r600_destroy_common_screen(&sscreen->b); + +#if HAVE_LLVM >= 0x0306 + LLVMDisposeTargetMachine(sscreen->tm); +#endif } #define SI_TILE_MODE_COLOR_2D_8BPP 14 @@ -476,6 +484,7 @@ static bool si_initialize_pipe_config(struct si_screen *sscreen) struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) { struct si_screen *sscreen = CALLOC_STRUCT(si_screen); + LLVMTargetRef r600_target; if (sscreen == NULL) { return NULL; } @@ -503,5 +512,13 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) /* Create the auxiliary context. This must be done last. */ sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL); +#if HAVE_LLVM >= 0x0306 + /* Initialize LLVM TargetMachine */ + r600_target = radeon_llvm_get_r600_target(); + sscreen->tm = LLVMCreateTargetMachine(r600_target, "r600--", + r600_get_llvm_processor_name(sscreen->b.family), + "+DumpCode", LLVMCodeGenLevelDefault, LLVMRelocDefault, + LLVMCodeModelDefault); +#endif return &sscreen->b.b; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 9ba4970b3ff..b2caef02eb1 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -28,6 +28,8 @@ #include "si_state.h" +#include <llvm-c/TargetMachine.h> + #ifdef PIPE_ARCH_BIG_ENDIAN #define SI_BIG_ENDIAN 1 #else @@ -50,6 +52,7 @@ struct si_compute; struct si_screen { struct r600_common_screen b; + LLVMTargetMachineRef tm; }; struct si_sampler_view { diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index ce59f0ebb66..ba42dab78bb 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2590,7 +2590,7 @@ int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader, shader->selector ? shader->selector->tokens : NULL); memset(&binary, 0, sizeof(binary)); r = radeon_llvm_compile(mod, &binary, - r600_get_llvm_processor_name(sscreen->b.family), dump); + r600_get_llvm_processor_name(sscreen->b.family), dump, sscreen->tm); if (r) { return r; |