ExecutionEngine::EECtorFn ExecutionEngine::JITCtor = 0;
ExecutionEngine::EECtorFn ExecutionEngine::InterpCtor = 0;
-ExecutionEngine::ExecutionEngine(ModuleProvider *P) {
+ExecutionEngine::ExecutionEngine(ModuleProvider *P) : LazyFunctionCreator(0) {
LazyCompilationDisabled = false;
Modules.push_back(P);
assert(P && "ModuleProvider is null?");
}
-ExecutionEngine::ExecutionEngine(Module *M) {
+ExecutionEngine::ExecutionEngine(Module *M) : LazyFunctionCreator(0) {
LazyCompilationDisabled = false;
assert(M && "Module is null?");
Modules.push_back(new ExistingModuleProvider(M));
delete Modules[i];
}
+/// removeModuleProvider - Remove a ModuleProvider from the list of modules.
+/// Release module from ModuleProvider.
+Module* ExecutionEngine::removeModuleProvider(ModuleProvider *P,
+ std::string *ErrInfo) {
+ for(SmallVector<ModuleProvider *, 1>::iterator I = Modules.begin(),
+ E = Modules.end(); I != E; ++I) {
+ ModuleProvider *MP = *I;
+ if (MP == P) {
+ Modules.erase(I);
+ return MP->releaseModule(ErrInfo);
+ }
+ }
+ return NULL;
+}
+
/// FindFunctionNamed - Search all of the active modules to find the one that
/// defines FnName. This is very slow operation and shouldn't be used for
/// general code.
if (EE) {
// Make sure we can resolve symbols in the program as well. The zero arg
// to the function tells DynamicLibrary to load the program, not a library.
- try {
- sys::DynamicLibrary::LoadLibraryPermanently(0);
- } catch (...) {
+ if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) {
+ delete EE;
+ return 0;
}
}
return EE;
}
+ExecutionEngine *ExecutionEngine::create(Module *M) {
+ return create(new ExistingModuleProvider(M));
+}
+
/// getPointerToGlobal - This returns the address of the specified global
/// value. This may involve code generation if it's a function.
///
else if (CE->getType() == Type::X86_FP80Ty) {
const uint64_t zero[] = {0, 0};
APFloat apf = APFloat(APInt(80, 2, zero));
- (void)apf.convertFromInteger(GV.IntVal.getRawData(),
+ (void)apf.convertFromZeroExtendedInteger(GV.IntVal.getRawData(),
GV.IntVal.getBitWidth(), false,
- APFloat::rmTowardZero);
+ APFloat::rmNearestTiesToEven);
GV.IntVal = apf.convertToAPInt();
}
return GV;
else if (CE->getType() == Type::X86_FP80Ty) {
const uint64_t zero[] = { 0, 0};
APFloat apf = APFloat(APInt(80, 2, zero));
- (void)apf.convertFromInteger(GV.IntVal.getRawData(),
+ (void)apf.convertFromZeroExtendedInteger(GV.IntVal.getRawData(),
GV.IntVal.getBitWidth(), true,
- APFloat::rmTowardZero);
+ APFloat::rmNearestTiesToEven);
GV.IntVal = apf.convertToAPInt();
}
return GV;
return;
} else if (const ConstantVector *CP = dyn_cast<ConstantVector>(Init)) {
unsigned ElementSize =
- getTargetData()->getTypeSize(CP->getType()->getElementType());
+ getTargetData()->getABITypeSize(CP->getType()->getElementType());
for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
InitializeMemory(CP->getOperand(i), (char*)Addr+i*ElementSize);
return;
StoreValueToMemory(Val, (GenericValue*)Addr, Init->getType());
return;
} else if (isa<ConstantAggregateZero>(Init)) {
- memset(Addr, 0, (size_t)getTargetData()->getTypeSize(Init->getType()));
+ memset(Addr, 0, (size_t)getTargetData()->getABITypeSize(Init->getType()));
return;
}
case Type::ArrayTyID: {
const ConstantArray *CPA = cast<ConstantArray>(Init);
unsigned ElementSize =
- getTargetData()->getTypeSize(CPA->getType()->getElementType());
+ getTargetData()->getABITypeSize(CPA->getType()->getElementType());
for (unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i)
InitializeMemory(CPA->getOperand(i), (char*)Addr+i*ElementSize);
return;
const Type *Ty = I->getType()->getElementType();
// Allocate some memory for it!
- unsigned Size = TD->getTypeSize(Ty);
+ unsigned Size = TD->getABITypeSize(Ty);
addGlobalMapping(I, new char[Size]);
} else {
// External variable reference. Try to use the dynamic loader to
DOUT << "Global '" << GV->getName() << "' -> " << GA << "\n";
const Type *ElTy = GV->getType()->getElementType();
- size_t GVSize = (size_t)getTargetData()->getTypeSize(ElTy);
+ size_t GVSize = (size_t)getTargetData()->getABITypeSize(ElTy);
if (GA == 0) {
// If it's not already specified, allocate memory for the global.
GA = new char[GVSize];