LLVM API Documentation

c/ExecutionEngine.h

Go to the documentation of this file.
00001 /*===-- llvm-c/ExecutionEngine.h - ExecutionEngine Lib C Iface --*- C++ -*-===*\
00002 |*                                                                            *|
00003 |*                     The LLVM Compiler Infrastructure                       *|
00004 |*                                                                            *|
00005 |* This file is distributed under the University of Illinois Open Source      *|
00006 |* License. See LICENSE.TXT for details.                                      *|
00007 |*                                                                            *|
00008 |*===----------------------------------------------------------------------===*|
00009 |*                                                                            *|
00010 |* This header declares the C interface to libLLVMExecutionEngine.o, which    *|
00011 |* implements various analyses of the LLVM IR.                                *|
00012 |*                                                                            *|
00013 |* Many exotic languages can interoperate with C code but have a harder time  *|
00014 |* with C++ due to name mangling. So in addition to C, this interface enables *|
00015 |* tools written in such languages.                                           *|
00016 |*                                                                            *|
00017 \*===----------------------------------------------------------------------===*/
00018 
00019 #ifndef LLVM_C_EXECUTIONENGINE_H
00020 #define LLVM_C_EXECUTIONENGINE_H
00021 
00022 #include "llvm-c/Core.h"
00023 #include "llvm-c/Target.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 void LLVMLinkInJIT(void);
00030 void LLVMLinkInInterpreter(void);
00031 
00032 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
00033 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
00034 
00035 /*===-- Operations on generic values --------------------------------------===*/
00036 
00037 LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
00038                                                 unsigned long long N,
00039                                                 int IsSigned);
00040 
00041 LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
00042 
00043 LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
00044 
00045 unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
00046 
00047 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
00048                                          int IsSigned);
00049 
00050 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
00051 
00052 double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
00053 
00054 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
00055 
00056 /*===-- Operations on execution engines -----------------------------------===*/
00057 
00058 int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
00059                               LLVMModuleProviderRef MP,
00060                               char **OutError);
00061 
00062 int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
00063                           LLVMModuleProviderRef MP,
00064                           char **OutError);
00065 
00066 int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
00067                           LLVMModuleProviderRef MP,
00068                           unsigned OptLevel,
00069                           char **OutError);
00070 
00071 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
00072 
00073 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
00074 
00075 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
00076 
00077 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
00078                           unsigned ArgC, const char * const *ArgV,
00079                           const char * const *EnvP);
00080 
00081 LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
00082                                     unsigned NumArgs,
00083                                     LLVMGenericValueRef *Args);
00084 
00085 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
00086 
00087 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
00088 
00089 int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
00090                              LLVMModuleProviderRef MP,
00091                              LLVMModuleRef *OutMod, char **OutError);
00092 
00093 int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
00094                      LLVMValueRef *OutFn);
00095 
00096 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
00097 
00098 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
00099                           void* Addr);
00100 
00101 void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global);
00102 
00103 #ifdef __cplusplus
00104 }
00105 
00106 namespace llvm {
00107   struct GenericValue;
00108   class ExecutionEngine;
00109   
00110   #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)   \
00111     inline ty *unwrap(ref P) {                          \
00112       return reinterpret_cast<ty*>(P);                  \
00113     }                                                   \
00114                                                         \
00115     inline ref wrap(const ty *P) {                      \
00116       return reinterpret_cast<ref>(const_cast<ty*>(P)); \
00117     }
00118   
00119   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue,    LLVMGenericValueRef   )
00120   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
00121   
00122   #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
00123 }
00124   
00125 #endif /* defined(__cplusplus) */
00126 
00127 #endif