@@ -413,8 +413,8 @@ Value* FunctionGenerator::LoadStateValue(uint32_t offset, Type* type,
|
||||
IRBuilder<>& b = *builder_;
|
||||
PointerType* pointerTy = PointerType::getUnqual(type);
|
||||
Function::arg_iterator args = gen_fn_->arg_begin();
|
||||
Value* statePtr = args;
|
||||
Value* address = b.CreateConstInBoundsGEP1_64(statePtr, offset);
|
||||
Value* state_ptr = args;
|
||||
Value* address = b.CreateInBoundsGEP(state_ptr, b.getInt32(offset));
|
||||
Value* ptr = b.CreatePointerCast(address, pointerTy);
|
||||
return b.CreateLoad(ptr, name);
|
||||
}
|
||||
@@ -424,8 +424,8 @@ void FunctionGenerator::StoreStateValue(uint32_t offset, Type* type,
|
||||
IRBuilder<>& b = *builder_;
|
||||
PointerType* pointerTy = PointerType::getUnqual(type);
|
||||
Function::arg_iterator args = gen_fn_->arg_begin();
|
||||
Value* statePtr = args;
|
||||
Value* address = b.CreateConstInBoundsGEP1_64(statePtr, offset);
|
||||
Value* state_ptr = args;
|
||||
Value* address = b.CreateInBoundsGEP(state_ptr, b.getInt32(offset));
|
||||
Value* ptr = b.CreatePointerCast(address, pointerTy);
|
||||
b.CreateStore(value, ptr);
|
||||
}
|
||||
@@ -861,7 +861,8 @@ Value* FunctionGenerator::ReadMemory(Value* addr, uint32_t size, bool extend) {
|
||||
}
|
||||
PointerType* pointerTy = PointerType::getUnqual(dataTy);
|
||||
|
||||
Value* address = b.CreateInBoundsGEP(GetMembase(), addr);
|
||||
Value* offset_addr = b.CreateAdd(addr, b.getInt64(size));
|
||||
Value* address = b.CreateInBoundsGEP(GetMembase(), offset_addr);
|
||||
Value* ptr = b.CreatePointerCast(address, pointerTy);
|
||||
return b.CreateLoad(ptr);
|
||||
}
|
||||
@@ -889,7 +890,8 @@ void FunctionGenerator::WriteMemory(Value* addr, uint32_t size, Value* value) {
|
||||
}
|
||||
PointerType* pointerTy = PointerType::getUnqual(dataTy);
|
||||
|
||||
Value* address = b.CreateInBoundsGEP(GetMembase(), addr);
|
||||
Value* offset_addr = b.CreateAdd(addr, b.getInt64(size));
|
||||
Value* address = b.CreateInBoundsGEP(GetMembase(), offset_addr);
|
||||
Value* ptr = b.CreatePointerCast(address, pointerTy);
|
||||
|
||||
// Truncate, if required.
|
||||
|
||||
@@ -126,6 +126,14 @@ int ModuleGenerator::Generate() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModuleGenerator::AddFunctionsToMap(
|
||||
std::tr1::unordered_map<uint32_t, llvm::Function*>& map) {
|
||||
for (std::map<uint32_t, CodegenFunction*>::iterator it = functions_.begin();
|
||||
it != functions_.end(); ++it) {
|
||||
map.insert(std::pair<uint32_t, Function*>(it->first, it->second->function));
|
||||
}
|
||||
}
|
||||
|
||||
ModuleGenerator::CodegenFunction* ModuleGenerator::GetCodegenFunction(
|
||||
uint32_t address) {
|
||||
std::map<uint32_t, CodegenFunction*>::iterator it = functions_.find(address);
|
||||
|
||||
Reference in New Issue
Block a user