mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
Make ExecutionEngine::updateGlobalMapping return the old mapping.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49206 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -96,9 +96,9 @@ public:
|
|||||||
/// any of those classes.
|
/// any of those classes.
|
||||||
sys::Mutex lock; // Used to make this class and subclasses thread-safe
|
sys::Mutex lock; // Used to make this class and subclasses thread-safe
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// ExecutionEngine Startup
|
// ExecutionEngine Startup
|
||||||
//===----------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
virtual ~ExecutionEngine();
|
virtual ~ExecutionEngine();
|
||||||
|
|
||||||
@ -176,8 +176,9 @@ public:
|
|||||||
|
|
||||||
/// updateGlobalMapping - Replace an existing mapping for GV with a new
|
/// updateGlobalMapping - Replace an existing mapping for GV with a new
|
||||||
/// address. This updates both maps as required. If "Addr" is null, the
|
/// address. This updates both maps as required. If "Addr" is null, the
|
||||||
/// entry for the global is removed from the mappings.
|
/// entry for the global is removed from the mappings. This returns the old
|
||||||
void updateGlobalMapping(const GlobalValue *GV, void *Addr);
|
/// value of the pointer, or null if it was not in the map.
|
||||||
|
void *updateGlobalMapping(const GlobalValue *GV, void *Addr);
|
||||||
|
|
||||||
/// getPointerToGlobalIfAvailable - This returns the address of the specified
|
/// getPointerToGlobalIfAvailable - This returns the address of the specified
|
||||||
/// global value if it is has already been codegen'd, otherwise it returns
|
/// global value if it is has already been codegen'd, otherwise it returns
|
||||||
@ -211,7 +212,8 @@ public:
|
|||||||
const GlobalValue *getGlobalValueAtAddress(void *Addr);
|
const GlobalValue *getGlobalValueAtAddress(void *Addr);
|
||||||
|
|
||||||
|
|
||||||
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, const Type *Ty);
|
void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr,
|
||||||
|
const Type *Ty);
|
||||||
void InitializeMemory(const Constant *Init, void *Addr);
|
void InitializeMemory(const Constant *Init, void *Addr);
|
||||||
|
|
||||||
/// recompileAndRelinkFunction - This method is used to force a function
|
/// recompileAndRelinkFunction - This method is used to force a function
|
||||||
|
@ -109,18 +109,30 @@ void ExecutionEngine::clearAllGlobalMappings() {
|
|||||||
/// updateGlobalMapping - Replace an existing mapping for GV with a new
|
/// updateGlobalMapping - Replace an existing mapping for GV with a new
|
||||||
/// address. This updates both maps as required. If "Addr" is null, the
|
/// address. This updates both maps as required. If "Addr" is null, the
|
||||||
/// entry for the global is removed from the mappings.
|
/// entry for the global is removed from the mappings.
|
||||||
void ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
|
void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
|
||||||
MutexGuard locked(lock);
|
MutexGuard locked(lock);
|
||||||
|
|
||||||
|
std::map<const GlobalValue*, void *> &Map = state.getGlobalAddressMap(locked);
|
||||||
|
|
||||||
// Deleting from the mapping?
|
// Deleting from the mapping?
|
||||||
if (Addr == 0) {
|
if (Addr == 0) {
|
||||||
state.getGlobalAddressMap(locked).erase(GV);
|
std::map<const GlobalValue*, void *>::iterator I = Map.find(GV);
|
||||||
if (!state.getGlobalAddressReverseMap(locked).empty())
|
void *OldVal;
|
||||||
state.getGlobalAddressReverseMap(locked).erase(Addr);
|
if (I == Map.end())
|
||||||
return;
|
OldVal = 0;
|
||||||
|
else {
|
||||||
|
OldVal = I->second;
|
||||||
|
Map.erase(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *&CurVal = state.getGlobalAddressMap(locked)[GV];
|
if (!state.getGlobalAddressReverseMap(locked).empty())
|
||||||
|
state.getGlobalAddressReverseMap(locked).erase(Addr);
|
||||||
|
return OldVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *&CurVal = Map[GV];
|
||||||
|
void *OldVal = CurVal;
|
||||||
|
|
||||||
if (CurVal && !state.getGlobalAddressReverseMap(locked).empty())
|
if (CurVal && !state.getGlobalAddressReverseMap(locked).empty())
|
||||||
state.getGlobalAddressReverseMap(locked).erase(CurVal);
|
state.getGlobalAddressReverseMap(locked).erase(CurVal);
|
||||||
CurVal = Addr;
|
CurVal = Addr;
|
||||||
@ -131,6 +143,7 @@ void ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
|
|||||||
assert((V == 0 || GV == 0) && "GlobalMapping already established!");
|
assert((V == 0 || GV == 0) && "GlobalMapping already established!");
|
||||||
V = GV;
|
V = GV;
|
||||||
}
|
}
|
||||||
|
return OldVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getPointerToGlobalIfAvailable - This returns the address of the specified
|
/// getPointerToGlobalIfAvailable - This returns the address of the specified
|
||||||
|
Reference in New Issue
Block a user