diff options
Diffstat (limited to 'tools/jello/Emitter.cpp')
-rw-r--r-- | tools/jello/Emitter.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/jello/Emitter.cpp b/tools/jello/Emitter.cpp index 0e54322..db83318 100644 --- a/tools/jello/Emitter.cpp +++ b/tools/jello/Emitter.cpp @@ -23,6 +23,7 @@ namespace { virtual void startBasicBlock(MachineBasicBlock &BB) {} virtual void emitByte(unsigned char B); virtual void emitPCRelativeDisp(Value *V); + virtual void emitGlobalAddress(GlobalValue *V); }; } @@ -44,6 +45,7 @@ static void *getMemory() { void Emitter::startFunction(MachineFunction &F) { CurBlock = (unsigned char *)getMemory(); CurByte = CurBlock; // Start writing at the beginning of the fn. + TheVM.addGlobalMapping(F.getFunction(), CurBlock); } #include <iostream> @@ -53,7 +55,6 @@ void Emitter::finishFunction(MachineFunction &F) { std::cerr << "Finished Code Generation of Function: " << F.getFunction()->getName() << ": " << CurByte-CurBlock << " bytes of text\n"; - TheVM.addGlobalMapping(F.getFunction(), CurBlock); } @@ -74,3 +75,8 @@ void Emitter::emitPCRelativeDisp(Value *V) { *(unsigned*)CurByte = ZeroAddr; // 4 byte offset CurByte += 4; } + +void Emitter::emitGlobalAddress(GlobalValue *V) { + *(void**)CurByte = TheVM.getPointerToGlobal(V); + CurByte += 4; +} |