1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[ORC] Add an OrcV2 C API function for configuring TargetMachines.

This commit is contained in:
Lang Hames 2020-04-10 14:07:51 -07:00
parent 8fc742c451
commit deddb8bde9
2 changed files with 34 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#define LLVM_C_ORC_H
#include "llvm-c/Error.h"
#include "llvm-c/TargetMachine.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
@ -202,6 +203,17 @@ void LLVMOrcDisposeThreadSafeModule(LLVMOrcThreadSafeModuleRef TSM);
LLVMErrorRef LLVMOrcJITTargetMachineBuilderDetectHost(
LLVMOrcJITTargetMachineBuilderRef *Result);
/**
* Create a JITTargetMachineBuilder from the given TargetMachine template.
*
* This operation takes ownership of the given TargetMachine and destroys it
* before returing. The resulting JITTargetMachineBuilder is owned by the client
* and must be passed to a consuming operation (e.g. LLVMOrcCreateLLJITBuilder)
* or disposed of by calling LLVMOrcDisposeJITTargetMachineBuilder.
*/
LLVMOrcJITTargetMachineBuilderRef
LLVMOrcJITTargetMachineBuilderCreateFromTargetMachine(LLVMTargetMachineRef TM);
/**
* Dispose of a JITTargetMachineBuilder.
*/

View File

@ -56,6 +56,8 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(JITTargetMachineBuilder,
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLJITBuilder, LLVMOrcLLJITBuilderRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLJIT, LLVMOrcLLJITRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)
LLVMOrcSymbolStringPoolEntryRef
LLVMOrcExecutionSessionIntern(LLVMOrcExecutionSessionRef ES, const char *Name) {
return wrap(
@ -140,6 +142,26 @@ LLVMErrorRef LLVMOrcJITTargetMachineBuilderDetectHost(
return LLVMErrorSuccess;
}
LLVMOrcJITTargetMachineBuilderRef
LLVMOrcJITTargetMachineBuilderFromTargetMachine(LLVMTargetMachineRef TM) {
auto *TemplateTM = unwrap(TM);
auto JTMB =
std::make_unique<JITTargetMachineBuilder>(TemplateTM->getTargetTriple());
(*JTMB)
.setCPU(TemplateTM->getTargetCPU().str())
.setRelocationModel(TemplateTM->getRelocationModel())
.setCodeModel(TemplateTM->getCodeModel())
.setCodeGenOptLevel(TemplateTM->getOptLevel())
.setFeatures(TemplateTM->getTargetFeatureString())
.setOptions(TemplateTM->Options);
LLVMDisposeTargetMachine(TM);
return wrap(JTMB.release());
}
void LLVMOrcDisposeJITTargetMachineBuilder(
LLVMOrcJITTargetMachineBuilderRef JTMB) {
delete unwrap(JTMB);