diff options
author | Marek Olšák <[email protected]> | 2018-06-30 00:54:30 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-07-02 14:34:39 -0400 |
commit | 32e413ca59f5c335bcce110af1f27b5c5d458b94 (patch) | |
tree | f3f9abf28171a54edaf0afb61aae2050570b1e06 /src/amd/common | |
parent | 49f7631c9fd94fbc5c892f70e5bcef54d0ec5043 (diff) |
ac: move all LLVM module initialization into ac_create_module
This removes some ugly code around module initialization.
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r-- | src/amd/common/ac_llvm_helper.cpp | 10 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_util.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/amd/common/ac_llvm_helper.cpp b/src/amd/common/ac_llvm_helper.cpp index 1a2aee3bc9a..495bd98da9c 100644 --- a/src/amd/common/ac_llvm_helper.cpp +++ b/src/amd/common/ac_llvm_helper.cpp @@ -61,6 +61,16 @@ bool ac_llvm_is_function(LLVMValueRef v) return LLVMGetValueKind(v) == LLVMFunctionValueKind; } +LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx) +{ + llvm::TargetMachine *TM = reinterpret_cast<llvm::TargetMachine*>(tm); + LLVMModuleRef module = LLVMModuleCreateWithNameInContext("mesa-shader", ctx); + + llvm::unwrap(module)->setTargetTriple(TM->getTargetTriple().getTriple()); + llvm::unwrap(module)->setDataLayout(TM->createDataLayout()); + return module; +} + LLVMBuilderRef ac_create_builder(LLVMContextRef ctx, enum ac_float_mode float_mode) { diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h index 0aa803c5bc1..6e6d15bb56c 100644 --- a/src/amd/common/ac_llvm_util.h +++ b/src/amd/common/ac_llvm_util.h @@ -83,6 +83,7 @@ void ac_dump_module(LLVMModuleRef module); LLVMValueRef ac_llvm_get_called_value(LLVMValueRef call); bool ac_llvm_is_function(LLVMValueRef v); +LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx); LLVMBuilderRef ac_create_builder(LLVMContextRef ctx, enum ac_float_mode float_mode); |