diff options
author | Marek Olšák <[email protected]> | 2018-07-04 01:11:47 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-07-04 15:48:18 -0400 |
commit | 0075e5fed8ae0e33b29a7b99bcdb0f480846d8b1 (patch) | |
tree | f7f8e26f811d68c26c77c68037d850d3d353ddbd /src/amd/common/ac_llvm_util.h | |
parent | c2ae9b4052701f8fde47947acb9ee47a878e1409 (diff) |
ac: add reusable helpers for direct LLVM compilation
This is basically LLVMTargetMachineEmitToMemoryBuffer inlined and reworked.
struct ac_compiler_passes (opaque type) contains the main pass manager.
ac_create_llvm_passes -- the result can go to thread local storage
ac_destroy_llvm_passes -- can be called by a destructor in TLS
ac_compile_module_to_binary -- from LLVMModuleRef to ac_shader_binary
The motivation is to do the expensive call addPassesToEmitFile once
per context or thread.
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/common/ac_llvm_util.h')
-rw-r--r-- | src/amd/common/ac_llvm_util.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h index c6ee537b74c..373fd8d28db 100644 --- a/src/amd/common/ac_llvm_util.h +++ b/src/amd/common/ac_llvm_util.h @@ -35,6 +35,9 @@ extern "C" { #endif +struct ac_shader_binary; +struct ac_compiler_passes; + enum ac_func_attr { AC_FUNC_ATTR_ALWAYSINLINE = (1 << 0), AC_FUNC_ATTR_INREG = (1 << 2), @@ -73,6 +76,7 @@ struct ac_llvm_compiler { LLVMTargetMachineRef tm; LLVMTargetLibraryInfoRef target_library_info; LLVMPassManagerRef passmgr; + struct ac_compiler_passes *passes; }; const char *ac_get_llvm_processor_name(enum radeon_family family); @@ -125,6 +129,11 @@ bool ac_init_llvm_compiler(struct ac_llvm_compiler *compiler, enum ac_target_machine_options tm_options); void ac_destroy_llvm_compiler(struct ac_llvm_compiler *compiler); +struct ac_compiler_passes *ac_create_llvm_passes(LLVMTargetMachineRef tm); +void ac_destroy_llvm_passes(struct ac_compiler_passes *p); +bool ac_compile_module_to_binary(struct ac_compiler_passes *p, LLVMModuleRef module, + struct ac_shader_binary *binary); + #ifdef __cplusplus } #endif |