///
virtual bool finishFunction(MachineFunction &F) = 0;
///
virtual bool finishFunction(MachineFunction &F) = 0;
- /// startFunctionStub - This callback is invoked when the JIT needs the
- /// address of a function that has not been code generated yet. The StubSize
- /// specifies the total size required by the stub. Stubs are not allowed to
- /// have constant pools, the can only use the other emitByte*/emitWord*
- /// methods.
+ /// startGVStub - This callback is invoked when the JIT needs the
+ /// address of a GV (e.g. function) that has not been code generated yet.
+ /// The StubSize specifies the total size required by the stub.
- virtual void startFunctionStub(const GlobalValue* F, unsigned StubSize,
- unsigned Alignment = 1) = 0;
+ virtual void startGVStub(const GlobalValue* GV, unsigned StubSize,
+ unsigned Alignment = 1) = 0;
- /// finishFunctionStub - This callback is invoked to terminate a function
- /// stub.
+ /// finishGVStub - This callback is invoked to terminate a GV stub.
- virtual void *finishFunctionStub(const GlobalValue* F) = 0;
+ virtual void *finishGVStub(const GlobalValue* F) = 0;
/// emitByte - This callback is invoked when a byte needs to be written to the
/// output stream.
/// emitByte - This callback is invoked when a byte needs to be written to the
/// output stream.
/// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE!
/// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE!
- void startFunctionStub(const GlobalValue* F, unsigned StubSize,
- unsigned Alignment = 1) {
+ void startGVStub(const GlobalValue* F, unsigned StubSize,
+ unsigned Alignment = 1) {
assert(0 && "JIT specific function called!");
abort();
}
assert(0 && "JIT specific function called!");
abort();
}
- void *finishFunctionStub(const GlobalValue *F) {
+ void *finishGVStub(const GlobalValue *F) {
assert(0 && "JIT specific function called!");
abort();
return 0;
assert(0 && "JIT specific function called!");
abort();
return 0;
virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { }
/// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE!
virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { }
/// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE!
- virtual void startFunctionStub(const GlobalValue* F, unsigned StubSize,
- unsigned Alignment = 1) {
+ virtual void startGVStub(const GlobalValue* F, unsigned StubSize,
+ unsigned Alignment = 1) {
assert(0 && "JIT specific function called!");
abort();
}
assert(0 && "JIT specific function called!");
abort();
}
- virtual void *finishFunctionStub(const GlobalValue* F) {
+ virtual void *finishGVStub(const GlobalValue* F) {
assert(0 && "JIT specific function called!");
abort();
return 0;
assert(0 && "JIT specific function called!");
abort();
return 0;
void initJumpTableInfo(MachineJumpTableInfo *MJTI);
void emitJumpTableInfo(MachineJumpTableInfo *MJTI);
void initJumpTableInfo(MachineJumpTableInfo *MJTI);
void emitJumpTableInfo(MachineJumpTableInfo *MJTI);
- virtual void startFunctionStub(const GlobalValue* F, unsigned StubSize,
+ virtual void startGVStub(const GlobalValue* GV, unsigned StubSize,
- virtual void* finishFunctionStub(const GlobalValue *F);
+ virtual void* finishGVStub(const GlobalValue *GV);
/// allocateSpace - Reserves space in the current block if any, or
/// allocate a new one of the given size.
/// allocateSpace - Reserves space in the current block if any, or
/// allocate a new one of the given size.
-void JITEmitter::startFunctionStub(const GlobalValue* F, unsigned StubSize,
- unsigned Alignment) {
+void JITEmitter::startGVStub(const GlobalValue* GV, unsigned StubSize,
+ unsigned Alignment) {
SavedBufferBegin = BufferBegin;
SavedBufferEnd = BufferEnd;
SavedCurBufferPtr = CurBufferPtr;
SavedBufferBegin = BufferBegin;
SavedBufferEnd = BufferEnd;
SavedCurBufferPtr = CurBufferPtr;
- BufferBegin = CurBufferPtr = MemMgr->allocateStub(F, StubSize, Alignment);
+ BufferBegin = CurBufferPtr = MemMgr->allocateStub(GV, StubSize, Alignment);
BufferEnd = BufferBegin+StubSize+1;
}
BufferEnd = BufferBegin+StubSize+1;
}
-void *JITEmitter::finishFunctionStub(const GlobalValue* F) {
+void *JITEmitter::finishGVStub(const GlobalValue* GV) {
NumBytes += getCurrentPCOffset();
// Invalidate the icache if necessary.
NumBytes += getCurrentPCOffset();
// Invalidate the icache if necessary.
void *ARMJITInfo::emitGlobalValueNonLazyPtr(const GlobalValue *GV, void *Ptr,
MachineCodeEmitter &MCE) {
void *ARMJITInfo::emitGlobalValueNonLazyPtr(const GlobalValue *GV, void *Ptr,
MachineCodeEmitter &MCE) {
- MCE.startFunctionStub(GV, 4, 4); // FIXME: Rename this.
+ MCE.startGVStub(GV, 4, 4);
MCE.emitWordLE((intptr_t)Ptr);
MCE.emitWordLE((intptr_t)Ptr);
- return MCE.finishFunctionStub(GV);
+ return MCE.finishGVStub(GV);
}
void *ARMJITInfo::emitFunctionStub(const Function* F, void *Fn,
}
void *ARMJITInfo::emitFunctionStub(const Function* F, void *Fn,
if (Fn != (void*)(intptr_t)ARMCompilationCallback) {
// Branch to the corresponding function addr.
// The stub is 8-byte size and 4-aligned.
if (Fn != (void*)(intptr_t)ARMCompilationCallback) {
// Branch to the corresponding function addr.
// The stub is 8-byte size and 4-aligned.
- MCE.startFunctionStub(F, 8, 4);
+ MCE.startGVStub(F, 8, 4);
MCE.emitWordLE(0xe51ff004); // LDR PC, [PC,#-4]
MCE.emitWordLE(addr); // addr of function
} else {
MCE.emitWordLE(0xe51ff004); // LDR PC, [PC,#-4]
MCE.emitWordLE(addr); // addr of function
} else {
//
// Branch and link to the compilation callback.
// The stub is 16-byte size and 4-byte aligned.
//
// Branch and link to the compilation callback.
// The stub is 16-byte size and 4-byte aligned.
- MCE.startFunctionStub(F, 16, 4);
+ MCE.startGVStub(F, 16, 4);
// Save LR so the callback can determine which stub called it.
// The compilation callback is responsible for popping this prior
// to returning.
// Save LR so the callback can determine which stub called it.
// The compilation callback is responsible for popping this prior
// to returning.
MCE.emitWordLE((intptr_t)ARMCompilationCallback);
}
MCE.emitWordLE((intptr_t)ARMCompilationCallback);
}
- return MCE.finishFunctionStub(F);
+ return MCE.finishGVStub(F);
}
intptr_t ARMJITInfo::resolveRelocDestAddr(MachineRelocation *MR) const {
}
intptr_t ARMJITInfo::resolveRelocDestAddr(MachineRelocation *MR) const {
MachineCodeEmitter &MCE) {
//assert(Fn == AlphaCompilationCallback && "Where are you going?\n");
//Do things in a stupid slow way!
MachineCodeEmitter &MCE) {
//assert(Fn == AlphaCompilationCallback && "Where are you going?\n");
//Do things in a stupid slow way!
- MCE.startFunctionStub(F, 19*4);
+ MCE.startGVStub(F, 19*4);
void* Addr = (void*)(intptr_t)MCE.getCurrentPCValue();
for (int x = 0; x < 19; ++ x)
MCE.emitWordLE(0);
EmitBranchToAt(Addr, Fn);
DOUT << "Emitting Stub to " << Fn << " at [" << Addr << "]\n";
void* Addr = (void*)(intptr_t)MCE.getCurrentPCValue();
for (int x = 0; x < 19; ++ x)
MCE.emitWordLE(0);
EmitBranchToAt(Addr, Fn);
DOUT << "Emitting Stub to " << Fn << " at [" << Addr << "]\n";
- return MCE.finishFunctionStub(F);
+ return MCE.finishGVStub(F);
}
TargetJITInfo::LazyResolverFn
}
TargetJITInfo::LazyResolverFn
// call. The code is the same except for one bit of the last instruction.
if (Fn != (void*)(intptr_t)PPC32CompilationCallback &&
Fn != (void*)(intptr_t)PPC64CompilationCallback) {
// call. The code is the same except for one bit of the last instruction.
if (Fn != (void*)(intptr_t)PPC32CompilationCallback &&
Fn != (void*)(intptr_t)PPC64CompilationCallback) {
- MCE.startFunctionStub(F, 7*4);
+ MCE.startGVStub(F, 7*4);
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
MCE.emitWordBE(0);
MCE.emitWordBE(0);
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
MCE.emitWordBE(0);
MCE.emitWordBE(0);
MCE.emitWordBE(0);
EmitBranchToAt(Addr, (intptr_t)Fn, false, is64Bit);
sys::Memory::InvalidateInstructionCache((void*)Addr, 7*4);
MCE.emitWordBE(0);
EmitBranchToAt(Addr, (intptr_t)Fn, false, is64Bit);
sys::Memory::InvalidateInstructionCache((void*)Addr, 7*4);
- return MCE.finishFunctionStub(F);
+ return MCE.finishGVStub(F);
- MCE.startFunctionStub(F, 10*4);
+ MCE.startGVStub(F, 10*4);
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
if (is64Bit) {
MCE.emitWordBE(0xf821ffb1); // stdu r1,-80(r1)
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
if (is64Bit) {
MCE.emitWordBE(0xf821ffb1); // stdu r1,-80(r1)
MCE.emitWordBE(0);
EmitBranchToAt(BranchAddr, (intptr_t)Fn, true, is64Bit);
sys::Memory::InvalidateInstructionCache((void*)Addr, 10*4);
MCE.emitWordBE(0);
EmitBranchToAt(BranchAddr, (intptr_t)Fn, true, is64Bit);
sys::Memory::InvalidateInstructionCache((void*)Addr, 10*4);
- return MCE.finishFunctionStub(F);
+ return MCE.finishGVStub(F);
void *X86JITInfo::emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
MachineCodeEmitter &MCE) {
#if defined (X86_64_JIT)
void *X86JITInfo::emitGlobalValueNonLazyPtr(const GlobalValue* GV, void *ptr,
MachineCodeEmitter &MCE) {
#if defined (X86_64_JIT)
- MCE.startFunctionStub(GV, 8, 8);
+ MCE.startGVStub(GV, 8, 8);
MCE.emitWordLE((unsigned)(intptr_t)ptr);
MCE.emitWordLE((unsigned)(((intptr_t)ptr) >> 32));
#else
MCE.emitWordLE((unsigned)(intptr_t)ptr);
MCE.emitWordLE((unsigned)(((intptr_t)ptr) >> 32));
#else
- MCE.startFunctionStub(GV, 4, 4);
+ MCE.startGVStub(GV, 4, 4);
MCE.emitWordLE((intptr_t)ptr);
#endif
MCE.emitWordLE((intptr_t)ptr);
#endif
- return MCE.finishFunctionStub(GV);
+ return MCE.finishGVStub(GV);
}
void *X86JITInfo::emitFunctionStub(const Function* F, void *Fn,
}
void *X86JITInfo::emitFunctionStub(const Function* F, void *Fn,
#endif
if (NotCC) {
#if defined (X86_64_JIT)
#endif
if (NotCC) {
#if defined (X86_64_JIT)
- MCE.startFunctionStub(F, 13, 4);
+ MCE.startGVStub(F, 13, 4);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE((unsigned)(intptr_t)Fn);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE((unsigned)(intptr_t)Fn);
MCE.emitByte(0xFF); // jmpq *r10
MCE.emitByte(2 | (4 << 3) | (3 << 6));
#else
MCE.emitByte(0xFF); // jmpq *r10
MCE.emitByte(2 | (4 << 3) | (3 << 6));
#else
- MCE.startFunctionStub(F, 5, 4);
+ MCE.startGVStub(F, 5, 4);
MCE.emitByte(0xE9);
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
MCE.emitByte(0xE9);
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
- return MCE.finishFunctionStub(F);
+ return MCE.finishGVStub(F);
}
#if defined (X86_64_JIT)
}
#if defined (X86_64_JIT)
- MCE.startFunctionStub(F, 14, 4);
+ MCE.startGVStub(F, 14, 4);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE((unsigned)(intptr_t)Fn);
MCE.emitByte(0x49); // REX prefix
MCE.emitByte(0xB8+2); // movabsq r10
MCE.emitWordLE((unsigned)(intptr_t)Fn);
MCE.emitByte(0xFF); // callq *r10
MCE.emitByte(2 | (2 << 3) | (3 << 6));
#else
MCE.emitByte(0xFF); // callq *r10
MCE.emitByte(2 | (2 << 3) | (3 << 6));
#else
- MCE.startFunctionStub(F, 6, 4);
+ MCE.startGVStub(F, 6, 4);
MCE.emitByte(0xE8); // Call with 32 bit pc-rel destination...
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
MCE.emitByte(0xCD); // Interrupt - Just a marker identifying the stub!
MCE.emitByte(0xE8); // Call with 32 bit pc-rel destination...
MCE.emitWordLE((intptr_t)Fn-MCE.getCurrentPCValue()-4);
#endif
MCE.emitByte(0xCD); // Interrupt - Just a marker identifying the stub!
- return MCE.finishFunctionStub(F);
+ return MCE.finishGVStub(F);
}
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the
}
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the