MipsJITInfo.h revision 8f5e8c1cd69fa77bea20140a7132ee2dea166c6d
18dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor//===- MipsJITInfo.h - Mips Implementation of the JIT Interface -*- C++ -*-===// 28dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// 38dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// The LLVM Compiler Infrastructure 48dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// 58dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// This file is distributed under the University of Illinois Open Source 68dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// License. See LICENSE.TXT for details. 78dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// 88dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor//===----------------------------------------------------------------------===// 98dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// 108dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// This file contains the declaration of the MipsJITInfo class. 118dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor// 128dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor//===----------------------------------------------------------------------===// 13aba43bb13b3aa3e81990989375fba3a902bfe1c2Douglas Gregor 148dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#ifndef MIPSJITINFO_H 158dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#define MIPSJITINFO_H 168dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor 178dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#include "MipsMachineFunction.h" 188dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#include "llvm/CodeGen/MachineConstantPool.h" 198dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#include "llvm/CodeGen/MachineFunction.h" 208dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#include "llvm/CodeGen/MachineJumpTableInfo.h" 218dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#include "llvm/Target/TargetJITInfo.h" 228dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#include "llvm/ADT/DenseMap.h" 238dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor#include "llvm/ADT/SmallVector.h" 24b28317a8e5e0e2953d1e5406d753d6c3c7f1e7d2Chris Lattner 258dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregornamespace llvm { 268dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregorclass MipsTargetMachine; 277e06390f8a60440d6fc5f0e633acdc2edd8ee924Douglas Gregor 288dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregorclass MipsJITInfo : public TargetJITInfo { 298dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor 308dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor bool IsPIC; 318dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor 328dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor public: 337e06390f8a60440d6fc5f0e633acdc2edd8ee924Douglas Gregor explicit MipsJITInfo() : 347e06390f8a60440d6fc5f0e633acdc2edd8ee924Douglas Gregor IsPIC(false) {} 358dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor 36390b4cc8b45a05612349269ef08faab3e4688f06Mike Stump /// replaceMachineCodeForFunction - Make it so that calling the function 37390b4cc8b45a05612349269ef08faab3e4688f06Mike Stump /// whose machine code is at OLD turns into a call to NEW, perhaps by 38390b4cc8b45a05612349269ef08faab3e4688f06Mike Stump /// overwriting OLD with a branch to NEW. This is used for self-modifying 394f722be4587a7a0dece399fb5405dda158971ae1Douglas Gregor /// code. 404f722be4587a7a0dece399fb5405dda158971ae1Douglas Gregor /// 418dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor virtual void replaceMachineCodeForFunction(void *Old, void *New); 423d7a12a50558c31d4351e923c15ab57688f4fdf2Douglas Gregor 438dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor // getStubLayout - Returns the size and alignment of the largest call stub 448dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor // on Mips. 458dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor virtual StubLayout getStubLayout(); 466477b69cc93e0a0ff15036d60d604f3544da0f29Douglas Gregor 47e53060fa78ad7e98352049f72787bdb7543e2a48Douglas Gregor /// emitFunctionStub - Use the specified JITCodeEmitter object to emit a 48d475b8d9e6f5ff0e6ab8d15667ce8a64c7cb9a4dDouglas Gregor /// small native function that simply calls the function at the specified 492dc0e64e57b2a1786fa53a7dbd1d5c8e255eadb0Douglas Gregor /// address. 50615c5d4674355ba830b9978f462ca7a8c5d15f85Douglas Gregor virtual void *emitFunctionStub(const Function* F, void *Fn, 5103b2b07aaef3a585aec13048a33356c7f635de72Douglas Gregor JITCodeEmitter &JCE); 52bb969ed4193e2eadabfaa0dfd0b94312b6146349Douglas Gregor 536477b69cc93e0a0ff15036d60d604f3544da0f29Douglas Gregor /// getLazyResolverFunction - Expose the lazy resolver to the JIT. 542dc0e64e57b2a1786fa53a7dbd1d5c8e255eadb0Douglas Gregor virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn); 555545e166a956a20d7a6b58408e251a1119025485Douglas Gregor 568dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor /// relocate - Before the JIT can run a block of code that has been emitted, 578dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor /// it must rewrite the code to contain the actual addresses of any 583d7a12a50558c31d4351e923c15ab57688f4fdf2Douglas Gregor /// referenced global symbols. 598dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor virtual void relocate(void *Function, MachineRelocation *MR, 608dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor unsigned NumRelocs, unsigned char* GOTBase); 615545e166a956a20d7a6b58408e251a1119025485Douglas Gregor 625545e166a956a20d7a6b58408e251a1119025485Douglas Gregor /// Initialize - Initialize internal stage for the function being JITted. 635545e166a956a20d7a6b58408e251a1119025485Douglas Gregor void Initialize(const MachineFunction &MF, bool isPIC) { 645545e166a956a20d7a6b58408e251a1119025485Douglas Gregor IsPIC = isPIC; 65e53060fa78ad7e98352049f72787bdb7543e2a48Douglas Gregor } 665545e166a956a20d7a6b58408e251a1119025485Douglas Gregor 678dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor}; 688dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor} 698dbc2694424b4e842b1d5ea39744a137b58600c3Douglas Gregor 704f722be4587a7a0dece399fb5405dda158971ae1Douglas Gregor#endif 714f722be4587a7a0dece399fb5405dda158971ae1Douglas Gregor