Cleanups to implement PR135

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10548 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-12-20 03:35:50 +00:00
parent 24b0a18c43
commit 1514b5b334

View File

@@ -35,11 +35,11 @@ class ExecutionEngine {
Module &CurMod; Module &CurMod;
const TargetData *TD; const TargetData *TD;
protected:
ModuleProvider *MP;
// GlobalAddress - A mapping between LLVM global values and their actualized // GlobalAddress - A mapping between LLVM global values and their actualized
// version... // version...
std::map<const GlobalValue*, void *> GlobalAddress; std::map<const GlobalValue*, void *> GlobalAddress;
protected:
ModuleProvider *MP;
void setTargetData(const TargetData &td) { void setTargetData(const TargetData &td) {
TD = &td; TD = &td;
@@ -63,7 +63,7 @@ public:
void addGlobalMapping(const GlobalValue *GV, void *Addr) { void addGlobalMapping(const GlobalValue *GV, void *Addr) {
void *&CurVal = GlobalAddress[GV]; void *&CurVal = GlobalAddress[GV];
assert(CurVal == 0 && "GlobalMapping already established!"); assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
CurVal = Addr; CurVal = Addr;
} }
@@ -106,13 +106,20 @@ public:
/// ///
virtual void *recompileAndRelinkFunction(Function *F) = 0; virtual void *recompileAndRelinkFunction(Function *F) = 0;
/// getOrEmitGlobalVariable - Return the address of the specified global
/// variable, possibly emitting it to memory if needed. This is used by the
/// Emitter.
virtual void *getOrEmitGlobalVariable(const GlobalVariable *GV) {
return getPointerToGlobal((GlobalValue*)GV);
}
protected: protected:
void emitGlobals(); void emitGlobals();
// EmitGlobalVariable - This method emits the specified global variable to the // EmitGlobalVariable - This method emits the specified global variable to the
// address specified in GlobalAddresses, or allocates new memory if it's not // address specified in GlobalAddresses, or allocates new memory if it's not
// already in the map. // already in the map.
void EmitGlobalVariable(GlobalVariable *GV); void EmitGlobalVariable(const GlobalVariable *GV);
GenericValue getConstantValue(const Constant *C); GenericValue getConstantValue(const Constant *C);
GenericValue LoadValueFromMemory(GenericValue *Ptr, const Type *Ty); GenericValue LoadValueFromMemory(GenericValue *Ptr, const Type *Ty);