LLVM API Documentation
#include "Interpreter.h"#include "llvm/DerivedTypes.h"#include "llvm/Module.h"#include "llvm/Config/config.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/Streams.h"#include "llvm/System/DynamicLibrary.h"#include "llvm/Target/TargetData.h"#include "llvm/Support/ManagedStatic.h"#include "llvm/System/Mutex.h"#include <csignal>#include <cstdio>#include <map>#include <cmath>#include <cstring>#include <ffi.h>
Go to the source code of this file.
Defines | |
| #define | USE_LIBFFI |
Typedefs | |
| typedef GenericValue(* | ExFunc )(const FunctionType *, const std::vector< GenericValue > &) |
| typedef void(* | RawFunc )() |
Functions | |
| static char | getTypeID (const Type *Ty) |
| static ExFunc | lookupFunction (const Function *F) |
| static ffi_type * | ffiTypeFor (const Type *Ty) |
| static void * | ffiValueFor (const Type *Ty, const GenericValue &AV, void *ArgDataPtr) |
| static bool | ffiInvoke (RawFunc Fn, Function *F, const std::vector< GenericValue > &ArgVals, const TargetData *TD, GenericValue &Result) |
| GenericValue | lle_X_atexit (const FunctionType *FT, const std::vector< GenericValue > &Args) |
| GenericValue | lle_X_exit (const FunctionType *FT, const std::vector< GenericValue > &Args) |
| GenericValue | lle_X_abort (const FunctionType *FT, const std::vector< GenericValue > &Args) |
| GenericValue | lle_X_sprintf (const FunctionType *FT, const std::vector< GenericValue > &Args) |
| GenericValue | lle_X_printf (const FunctionType *FT, const std::vector< GenericValue > &Args) |
| static void | ByteswapSCANFResults (LLVMContext &C, const char *Fmt, void *Arg0, void *Arg1, void *Arg2, void *Arg3, void *Arg4, void *Arg5, void *Arg6, void *Arg7, void *Arg8) |
| GenericValue | lle_X_sscanf (const FunctionType *FT, const std::vector< GenericValue > &args) |
| GenericValue | lle_X_scanf (const FunctionType *FT, const std::vector< GenericValue > &args) |
| GenericValue | lle_X_fprintf (const FunctionType *FT, const std::vector< GenericValue > &Args) |
Variables | |
| static ManagedStatic< sys::Mutex > | FunctionsLock |
| static ManagedStatic< std::map < const Function *, ExFunc > > | ExportedFunctions |
| static std::map< std::string, ExFunc > | FuncNames |
| static ManagedStatic< std::map < const Function *, RawFunc > > | RawFunctions |
| static Interpreter * | TheInterpreter |
| #define USE_LIBFFI |
Definition at line 41 of file ExternalFunctions.cpp.
| typedef GenericValue(* ExFunc)(const FunctionType *, const std::vector< GenericValue > &) |
Definition at line 52 of file ExternalFunctions.cpp.
| typedef void(* RawFunc)() |
Definition at line 58 of file ExternalFunctions.cpp.
| static void ByteswapSCANFResults | ( | LLVMContext & | C, | |
| const char * | Fmt, | |||
| void * | Arg0, | |||
| void * | Arg1, | |||
| void * | Arg2, | |||
| void * | Arg3, | |||
| void * | Arg4, | |||
| void * | Arg5, | |||
| void * | Arg6, | |||
| void * | Arg7, | |||
| void * | Arg8 | |||
| ) | [static] |
Definition at line 421 of file ExternalFunctions.cpp.
References Arg, llvm::Type::getDoubleTy(), llvm::Type::getFloatTy(), llvm::Type::getInt16Ty(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::Type::getInt8Ty(), GV, llvm::Intrinsic::memcpy, Out, llvm::ExecutionEngine::StoreValueToMemory(), and Ty.
Referenced by lle_X_scanf(), and lle_X_sscanf().
| static bool ffiInvoke | ( | RawFunc | Fn, | |
| Function * | F, | |||
| const std::vector< GenericValue > & | ArgVals, | |||
| const TargetData * | TD, | |||
| GenericValue & | Result | |||
| ) | [static] |
Definition at line 182 of file ExternalFunctions.cpp.
References A, llvm::Function::arg_begin(), llvm::Function::arg_end(), llvm::Function::arg_size(), llvm::GenericValue::DoubleVal, E, ffiTypeFor(), ffiValueFor(), llvm::GenericValue::FloatVal, llvm::Function::getFunctionType(), llvm::Value::getName(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::Type::getTypeID(), llvm::TargetData::getTypeStoreSize(), llvm::GenericValue::IntVal, llvm::Function::isVarArg(), llvm::llvm_report_error(), llvm::GenericValue::PointerVal, RetTy, and llvm::cl::values().
Referenced by llvm::Interpreter::callExternalFunction().
| static ffi_type* ffiTypeFor | ( | const Type * | Ty | ) | [static] |
Definition at line 114 of file ExternalFunctions.cpp.
References llvm::Type::getTypeID(), and llvm::llvm_report_error().
Referenced by ffiInvoke().
| static void* ffiValueFor | ( | const Type * | Ty, | |
| const GenericValue & | AV, | |||
| void * | ArgDataPtr | |||
| ) | [static] |
Definition at line 134 of file ExternalFunctions.cpp.
References llvm::GenericValue::DoubleVal, llvm::Type::getTypeID(), llvm::APInt::getZExtValue(), llvm::GVTOP(), llvm::GenericValue::IntVal, and llvm::llvm_report_error().
Referenced by ffiInvoke().
| static char getTypeID | ( | const Type * | Ty | ) | [static] |
Definition at line 64 of file ExternalFunctions.cpp.
References llvm::Type::getTypeID().
Referenced by llvm::ConstantStruct::ConstantStruct(), LLVMCreateGenericValueOfFloat(), LLVMGenericValueToFloat(), LLVMGetTypeKind(), and lookupFunction().
| GenericValue lle_X_abort | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | Args | |||
| ) |
Definition at line 320 of file ExternalFunctions.cpp.
| GenericValue lle_X_atexit | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | Args | |||
| ) |
Definition at line 303 of file ExternalFunctions.cpp.
References llvm::Interpreter::addAtExitHandler(), GV, llvm::GVTOP(), and llvm::GenericValue::IntVal.
| GenericValue lle_X_exit | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | Args | |||
| ) |
| GenericValue lle_X_fprintf | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | Args | |||
| ) |
Definition at line 536 of file ExternalFunctions.cpp.
References GV, llvm::GVTOP(), lle_X_sprintf(), and llvm::PTOGV().
| GenericValue lle_X_printf | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | Args | |||
| ) |
Definition at line 410 of file ExternalFunctions.cpp.
References llvm::cout(), GV, lle_X_sprintf(), and llvm::PTOGV().
| GenericValue lle_X_scanf | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | args | |||
| ) |
Definition at line 517 of file ExternalFunctions.cpp.
References ByteswapSCANFResults(), llvm::Type::getContext(), GV, llvm::GVTOP(), and llvm::GenericValue::IntVal.
| GenericValue lle_X_sprintf | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | Args | |||
| ) |
Definition at line 330 of file ExternalFunctions.cpp.
References llvm::cerr(), llvm::TargetData::getPointerSizeInBits(), llvm::ExecutionEngine::getTargetData(), GV, llvm::GVTOP(), and llvm::GenericValue::IntVal.
Referenced by lle_X_fprintf(), and lle_X_printf().
| GenericValue lle_X_sscanf | ( | const FunctionType * | FT, | |
| const std::vector< GenericValue > & | args | |||
| ) |
Definition at line 499 of file ExternalFunctions.cpp.
References ByteswapSCANFResults(), llvm::Type::getContext(), GV, llvm::GVTOP(), and llvm::GenericValue::IntVal.
Definition at line 92 of file ExternalFunctions.cpp.
References FuncNames, llvm::Type::getContainedType(), llvm::Function::getFunctionType(), llvm::Value::getNameStr(), llvm::Type::getNumContainedTypes(), getTypeID(), and llvm::sys::DynamicLibrary::SearchForAddressOfSymbol().
Referenced by llvm::Interpreter::callExternalFunction().
ManagedStatic<std::map<const Function *, ExFunc> > ExportedFunctions [static] |
Definition at line 54 of file ExternalFunctions.cpp.
ManagedStatic<sys::Mutex> FunctionsLock [static] |
Definition at line 50 of file ExternalFunctions.cpp.
ManagedStatic<std::map<const Function *, RawFunc> > RawFunctions [static] |
Definition at line 59 of file ExternalFunctions.cpp.
Interpreter* TheInterpreter [static] |
Definition at line 62 of file ExternalFunctions.cpp.