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 typedef struct LLVMOpaqueGenericValue *LLVMGenericValueRef;
00030 typedef struct LLVMOpaqueExecutionEngine *LLVMExecutionEngineRef;
00031 
00032 /*===-- Operations on generic values --------------------------------------===*/
00033 
00034 LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
00035                                                 unsigned long long N,
00036                                                 int IsSigned);
00037 
00038 LLVMGenericValueRef LLVMCreateGenericValueOfPointer(void *P);
00039 
00040 LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef Ty, double N);
00041 
00042 unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef);
00043 
00044 unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenVal,
00045                                          int IsSigned);
00046 
00047 void *LLVMGenericValueToPointer(LLVMGenericValueRef GenVal);
00048 
00049 double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal);
00050 
00051 void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal);
00052 
00053 /*===-- Operations on execution engines -----------------------------------===*/
00054 
00055 int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
00056                               LLVMModuleProviderRef MP,
00057                               char **OutError);
00058 
00059 int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
00060                           LLVMModuleProviderRef MP,
00061                           char **OutError);
00062 
00063 int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
00064                           LLVMModuleProviderRef MP,
00065                           int Fast,
00066                           char **OutError);
00067 
00068 void LLVMDisposeExecutionEngine(LLVMExecutionEngineRef EE);
00069 
00070 void LLVMRunStaticConstructors(LLVMExecutionEngineRef EE);
00071 
00072 void LLVMRunStaticDestructors(LLVMExecutionEngineRef EE);
00073 
00074 int LLVMRunFunctionAsMain(LLVMExecutionEngineRef EE, LLVMValueRef F,
00075                           unsigned ArgC, const char * const *ArgV,
00076                           const char * const *EnvP);
00077 
00078 LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F,
00079                                     unsigned NumArgs,
00080                                     LLVMGenericValueRef *Args);
00081 
00082 void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F);
00083 
00084 void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP);
00085 
00086 int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
00087                              LLVMModuleProviderRef MP,
00088                              LLVMModuleRef *OutMod, char **OutError);
00089 
00090 int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
00091                      LLVMValueRef *OutFn);
00092 
00093 LLVMTargetDataRef LLVMGetExecutionEngineTargetData(LLVMExecutionEngineRef EE);
00094 
00095 void LLVMAddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
00096                           void* Addr);
00097 
00098 #ifdef __cplusplus
00099 }
00100 
00101 namespace llvm {
00102   class GenericValue;
00103   class ExecutionEngine;
00104   
00105   #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)   \
00106     inline ty *unwrap(ref P) {                          \
00107       return reinterpret_cast<ty*>(P);                  \
00108     }                                                   \
00109                                                         \
00110     inline ref wrap(const ty *P) {                      \
00111       return reinterpret_cast<ref>(const_cast<ty*>(P)); \
00112     }
00113   
00114   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue,    LLVMGenericValueRef   )
00115   DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
00116   
00117   #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
00118 }
00119   
00120 #endif /* defined(__cplusplus) */
00121 
00122 #endif



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.