forked from OSchip/llvm-project
[ORC] Add an OrcV2 C API function for configuring TargetMachines.
This commit is contained in:
parent
1e93b3d8a7
commit
59ed45b483
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue