14 #define DEBUG_TYPE "jit"
38 #ifndef __USER_LABEL_PREFIX__
39 #define __USER_LABEL_PREFIX__
41 #define GETASMPREFIX2(X) #X
42 #define GETASMPREFIX(X) GETASMPREFIX2(X)
43 #define ASMPREFIX GETASMPREFIX(__USER_LABEL_PREFIX__)
56 ".globl " ASMPREFIX "ARMCompilationCallback\n"
62 "stmdb sp!, {r0, r1, r2, r3, lr}\n"
63 #if (defined(__VFP_FP__) && !defined(__SOFTFP__))
64 "vstmdb sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
71 "bl " ASMPREFIX "ARMCompilationCallbackC\n"
86 #if (defined(__VFP_FP__) && !defined(__SOFTFP__))
88 "vldmia sp!, {d0, d1, d2, d3, d4, d5, d6, d7}\n"
102 "ldmia sp!, {r0, r1, r2, r3, lr}\n"
105 #else // Not an ARM host
107 llvm_unreachable(
"Cannot call ARMCompilationCallback() on a non-ARM arch!");
144 uint8_t *Cur = Buffer;
147 GV, Buffer,
sizeof(Buffer), 4);
173 errs() <<
"JIT: Indirect symbol emitted at [" << LazyPtr
174 <<
"] for GV '" << F->
getName() <<
"'\n";
176 errs() <<
"JIT: Stub emitted at [" << LazyPtr
177 <<
"] for external function at '" << Fn <<
"'\n");
256 "Can't handle this machine constant pool entry yet!");
268 unsigned NumRelocs,
unsigned char* GOTBase) {
269 for (
unsigned i = 0; i != NumRelocs; ++i, ++MR) {
271 intptr_t ResultPtr = resolveRelocDestAddr(MR);
278 ResultPtr = ResultPtr - (
intptr_t)RelocPos - 8;
285 ResultPtr = - ResultPtr;
290 ResultPtr = ResultPtr >> 2;
291 *((
intptr_t*)RelocPos) |= ResultPtr;
310 ResultPtr = ResultPtr - (
intptr_t)RelocPos - 8;
311 ResultPtr = (ResultPtr & 0x03FFFFFC) >> 2;
312 assert(ResultPtr >= -33554432 && ResultPtr <= 33554428);
313 *((
intptr_t*)RelocPos) |= ResultPtr;
318 ResultPtr = ResultPtr - (
intptr_t)RelocPos - 8;
319 *((
intptr_t*)RelocPos) |= ResultPtr;
323 ResultPtr = ResultPtr & 0xFFFF;
324 *((
intptr_t*)RelocPos) |= ResultPtr & 0xFFF;
325 *((
intptr_t*)RelocPos) |= ((ResultPtr >> 12) & 0xF) << 16;
329 ResultPtr = (ResultPtr >> 16) & 0xFFFF;
330 *((
intptr_t*)RelocPos) |= ResultPtr & 0xFFF;
331 *((
intptr_t*)RelocPos) |= ((ResultPtr >> 12) & 0xF) << 16;
void emitAlignment(unsigned Alignment)
unsigned getRelocationType() const
static bool setRangeWritable(const void *Addr, size_t Size)
virtual void replaceMachineCodeForFunction(void *Old, void *New)
unsigned getJumpTableIndex() const
virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn)
getLazyResolverFunction - Expose the lazy resolver to the JIT.
unsigned getConstantPoolIndex() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
StringRef getName() const
void *(* JITCompilerFn)(void *)
static void InvalidateInstructionCache(const void *Addr, size_t Len)
#define llvm_unreachable(msg)
intptr_t getConstantPoolEntryAddr(unsigned CPI) const
intptr_t getConstantVal() const
bool mustAddCurrentAddress() const
static TargetJITInfo::JITCompilerFn JITCompilerFunction
static void emitWordLEInto(uint8_t *&Buf, uint32_t W)
intptr_t getJumpTableBaseAddr(unsigned JTI) const
void addIndirectSymAddr(void *SymAddr, intptr_t IndSymAddr)
intptr_t getMachineCodeOffset() const
virtual void * emitGlobalValueIndirectSym(const GlobalValue *GV, void *ptr, JITCodeEmitter &JCE)
virtual void * emitFunctionStub(const Function *F, void *Fn, JITCodeEmitter &JCE)
static bool setRangeExecutable(const void *Addr, size_t Size)
void * getResultPointer() const
virtual StubLayout getStubLayout()
Returns the maximum size and alignment for a call stub on this target.
virtual uintptr_t getCurrentPCValue() const
virtual void * allocIndirectGV(const GlobalValue *GV, const uint8_t *Buffer, size_t Size, unsigned Alignment)=0
void emitWordLE(uint32_t W)
virtual void relocate(void *Function, MachineRelocation *MR, unsigned NumRelocs, unsigned char *GOTBase)
void ARMCompilationCallbackC(intptr_t StubAddr)
intptr_t getIndirectSymAddr(void *Addr) const
unsigned getLabelId() const
unsigned char getPCAdjustment() const
intptr_t getPCLabelAddr(unsigned Id) const
void ARMCompilationCallback()
Records the required size and alignment for a call stub in bytes.