ExecutionEngine.h revision 3574eca1b02600bac4e625297f4ecf745f4c4f32
1bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner//===- ExecutionEngine.h - Abstract Execution Engine Interface --*- C++ -*-===// 2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// The LLVM Compiler Infrastructure 46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source 67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details. 7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===// 9bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner// 10bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner// This file defines the abstract interface that implements execution support 11bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner// for LLVM. 12bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner// 13bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner//===----------------------------------------------------------------------===// 14bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner 159f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner#ifndef LLVM_EXECUTION_ENGINE_H 169f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner#define LLVM_EXECUTION_ENGINE_H 17bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner 18439661395fd2a2a832dba01c65bc88718528313cEvan Cheng#include "llvm/MC/MCCodeGenInfo.h" 19fe854034677f59baca1e38075e71f6efca247a03Chris Lattner#include "llvm/ADT/SmallVector.h" 204688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin#include "llvm/ADT/StringRef.h" 2123e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin#include "llvm/ADT/ValueMap.h" 22515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher#include "llvm/ADT/DenseMap.h" 2350bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper#include "llvm/Support/ErrorHandling.h" 244c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin#include "llvm/Support/ValueHandle.h" 251f6efa3996dd1929fbc129203ce5009b620e6969Michael J. Spencer#include "llvm/Support/Mutex.h" 2698a366d547772010e94609e4584489b3e5ce0043Bill Wendling#include "llvm/Target/TargetMachine.h" 27d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne#include "llvm/Target/TargetOptions.h" 2850bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper#include <vector> 2950bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper#include <map> 3050bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper#include <string> 31d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 32d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm { 33d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 349d87eb19be82b28d288e38eab3bbe145060a0701Reid Spencerstruct GenericValue; 35bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattnerclass Constant; 364c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskinclass ExecutionEngine; 37bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattnerclass Function; 383ddc05bdde6ed65f93340ea467d362e80c0ceb9cChris Lattnerclass GlobalVariable; 39b6c54ed8f50a351989993a5ef88507abc6d63e2dMisha Brukmanclass GlobalValue; 40df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskinclass JITEventListener; 41df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskinclass JITMemoryManager; 42df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskinclass MachineCodeInfo; 43bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattnerclass Module; 44df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskinclass MutexGuard; 453574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmowclass DataLayout; 469ea47179e647e806a2c67639bfead9d254514e59Dylan Noblesmithclass Triple; 47b6c54ed8f50a351989993a5ef88507abc6d63e2dMisha Brukmanclass Type; 48bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner 4948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar/// \brief Helper class for helping synchronize access to the global address map 5048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar/// table. 51ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencerclass ExecutionEngineState { 524c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskinpublic: 5323e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin struct AddressMapConfig : public ValueMapConfig<const GlobalValue*> { 5423e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin typedef ExecutionEngineState *ExtraData; 5523e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin static sys::Mutex *getMutex(ExecutionEngineState *EES); 5623e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin static void onDelete(ExecutionEngineState *EES, const GlobalValue *Old); 5723e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin static void onRAUW(ExecutionEngineState *, const GlobalValue *, 5823e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin const GlobalValue *); 594c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin }; 604c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin 6123e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin typedef ValueMap<const GlobalValue *, void *, AddressMapConfig> 6223e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin GlobalAddressMapTy; 6323e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin 64ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencerprivate: 654c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin ExecutionEngine &EE; 664c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin 67c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// GlobalAddressMap - A mapping between LLVM global values and their 68c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// actualized version... 6923e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin GlobalAddressMapTy GlobalAddressMap; 70c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner 71c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// GlobalAddressReverseMap - This is the reverse mapping of GlobalAddressMap, 72c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// used to convert raw addresses into the LLVM global value that is emitted 73c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// at the address. This map is not computed unless getGlobalValueAtAddress 74c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// is called at some point. 750d5bd59553375dc85ac04c81ef48ef74c9e7193eJeffrey Yasskin std::map<void *, AssertingVH<const GlobalValue> > GlobalAddressReverseMap; 76ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer 77ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencerpublic: 7823e5fcfec4640955fec41dc8348f467adf1a3e56Jeffrey Yasskin ExecutionEngineState(ExecutionEngine &EE); 794c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin 8048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar GlobalAddressMapTy &getGlobalAddressMap(const MutexGuard &) { 81ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer return GlobalAddressMap; 82ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer } 83ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer 840d5bd59553375dc85ac04c81ef48ef74c9e7193eJeffrey Yasskin std::map<void*, AssertingVH<const GlobalValue> > & 8513d57320bd212483463d4f8992d5787b29eda5dfBill Wendling getGlobalAddressReverseMap(const MutexGuard &) { 86ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer return GlobalAddressReverseMap; 87ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer } 88c89d27a440370455336202b2a8f25eb9c73e67bcJeffrey Yasskin 8948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// \brief Erase an entry from the mapping table. 9048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// 91c5252da873d547a19069eaf9030fec203f128f66Dmitri Gribenko /// \returns The address that \p ToUnmap was happed to. 92c89d27a440370455336202b2a8f25eb9c73e67bcJeffrey Yasskin void *RemoveMapping(const MutexGuard &, const GlobalValue *ToUnmap); 93ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer}; 94ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer 9548dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar/// \brief Abstract interface for implementation execution of LLVM modules, 9648dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar/// designed to support both interpreter and just-in-time (JIT) compiler 9748dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar/// implementations. 98ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencerclass ExecutionEngine { 9948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// The state object holding the global address mapping, which must be 10048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// accessed synchronously. 10148dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar // 10248dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar // FIXME: There is no particular need the entire map needs to be 10348dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar // synchronized. Wouldn't a reader-writer design be better here? 1044c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin ExecutionEngineState EEState; 10548dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar 10648dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// The target data for the platform for which execution is being performed. 1073574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmow const DataLayout *TD; 10848dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar 10948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// Whether lazy JIT compilation is enabled. 110dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin bool CompilingLazily; 11148dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar 11248dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// Whether JIT compilation of external global variables is allowed. 113446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng bool GVCompilationDisabled; 11448dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar 11548dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// Whether the JIT should perform lookups of external symbols (e.g., 11648dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// using dlsym). 117e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner bool SymbolSearchingDisabled; 118d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner 1194b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner friend class EngineBuilder; // To allow access to JITCtor and InterpCtor. 1204b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 1211514b5b334c72e1e190fe1ce2bce7bf7d8a91c1aChris Lattnerprotected: 12248dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// The list of Modules that we are JIT'ing from. We use a SmallVector to 12348dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// optimize for the case where there is only one module. 124f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin SmallVector<Module*, 1> Modules; 125f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 1263574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmow void setDataLayout(const DataLayout *td) { TD = td; } 127f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 12846fa139e26be6ebc00be2fb45820c2560dd22a32Nicolas Geoffray /// getMemoryforGV - Allocate memory for a global variable. 12948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar virtual char *getMemoryForGV(const GlobalVariable *GV); 130b6c54ed8f50a351989993a5ef88507abc6d63e2dMisha Brukman 131765c93cefda367d8e5a8e0afcd610a7e15bbd987Chris Lattner // To avoid having libexecutionengine depend on the JIT and interpreter 1326d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar // libraries, the execution engine implementations set these functions to ctor 1336d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar // pointers at startup time if they are linked in. 1344688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin static ExecutionEngine *(*JITCtor)( 1354688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin Module *M, 1364688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin std::string *ErrorStr, 1374688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin JITMemoryManager *JMM, 1384688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin bool GVsWithCode, 139c5b28580a94e247300e5d3ccf532e153f2ae6f12Dylan Noblesmith TargetMachine *TM); 1406d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar static ExecutionEngine *(*MCJITCtor)( 1416d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar Module *M, 1426d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar std::string *ErrorStr, 1436d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar JITMemoryManager *JMM, 1446d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar bool GVsWithCode, 145c5b28580a94e247300e5d3ccf532e153f2ae6f12Dylan Noblesmith TargetMachine *TM); 146026fa8782cd59f79ac6335e54a0d1cc882a0b626Jim Grosbach static ExecutionEngine *(*InterpCtor)(Module *M, std::string *ErrorStr); 147d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner 148d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner /// LazyFunctionCreator - If an unknown function is needed, this function 14948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// pointer is invoked to create it. If this returns null, the JIT will 15048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// abort. 15148dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar void *(*LazyFunctionCreator)(const std::string &); 152f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 153b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands /// ExceptionTableRegister - If Exception Handling is set, the JIT will 154b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands /// register dwarf tables with this function. 155afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray typedef void (*EERegisterFn)(void*); 156b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands EERegisterFn ExceptionTableRegister; 157b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands EERegisterFn ExceptionTableDeregister; 158515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher /// This maps functions to their exception tables frames. 159515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher DenseMap<const Function*, void*> AllExceptionTables; 160515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher 161afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray 162bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattnerpublic: 16348dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// lock - This lock protects the ExecutionEngine, JIT, JITResolver and 164765c93cefda367d8e5a8e0afcd610a7e15bbd987Chris Lattner /// JITEmitter classes. It must be held while changing the internal state of 165765c93cefda367d8e5a8e0afcd610a7e15bbd987Chris Lattner /// any of those classes. 16648dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar sys::Mutex lock; 167ee448630bdf7eb6037fe2c50518d32010c433ca3Reid Spencer 168f4cc3096fd893cdef5b5c2664ebff8c13a07ad51Chris Lattner //===--------------------------------------------------------------------===// 1699f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner // ExecutionEngine Startup 170f4cc3096fd893cdef5b5c2664ebff8c13a07ad51Chris Lattner //===--------------------------------------------------------------------===// 171ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 1729f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner virtual ~ExecutionEngine(); 173bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner 1749f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner /// create - This is the factory method for creating an execution engine which 1759f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner /// is appropriate for the current machine. This takes ownership of the 176f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// module. 17748dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// 17848dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// \param GVsWithCode - Allocating globals with code breaks 17948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// freeMachineCodeForFunction and is probably unsafe and bad for performance. 18048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// However, we have clients who depend on this behavior, so we must support 1817a2bdde0a0eebcd2125055e0eacaca040f0b766cChris Lattner /// it. Eventually, when we're willing to break some backwards compatibility, 18248dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// this flag should be flipped to false, so that by default 18348dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// freeMachineCodeForFunction works. 184f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin static ExecutionEngine *create(Module *M, 1859f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner bool ForceInterpreter = false, 186502f20b17ede40de84503010b7699b328a4f2867Evan Cheng std::string *ErrorStr = 0, 18798a366d547772010e94609e4584489b3e5ce0043Bill Wendling CodeGenOpt::Level OptLevel = 188026fa8782cd59f79ac6335e54a0d1cc882a0b626Jim Grosbach CodeGenOpt::Default, 189489393d7b92107cc3de17d8dbe7dd11ab7395fdcJeffrey Yasskin bool GVsWithCode = true); 190489393d7b92107cc3de17d8dbe7dd11ab7395fdcJeffrey Yasskin 19134c9433004cabd4760987dce4804a91c84908219Chris Lattner /// createJIT - This is the factory method for creating a JIT for the current 19234c9433004cabd4760987dce4804a91c84908219Chris Lattner /// machine, it does not fall back to the interpreter. This takes ownership 193f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// of the Module and JITMemoryManager if successful. 1941d929216916dc992f8643dda971aac58d47c7765Daniel Dunbar /// 1951d929216916dc992f8643dda971aac58d47c7765Daniel Dunbar /// Clients should make sure to initialize targets prior to calling this 1961d929216916dc992f8643dda971aac58d47c7765Daniel Dunbar /// function. 197f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin static ExecutionEngine *createJIT(Module *M, 19834c9433004cabd4760987dce4804a91c84908219Chris Lattner std::string *ErrorStr = 0, 199502f20b17ede40de84503010b7699b328a4f2867Evan Cheng JITMemoryManager *JMM = 0, 20098a366d547772010e94609e4584489b3e5ce0043Bill Wendling CodeGenOpt::Level OptLevel = 201026fa8782cd59f79ac6335e54a0d1cc882a0b626Jim Grosbach CodeGenOpt::Default, 20288b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher bool GVsWithCode = true, 203439661395fd2a2a832dba01c65bc88718528313cEvan Cheng Reloc::Model RM = Reloc::Default, 2043472766f9eb7d66f234c390ce1b3a8b76f0ee9ceDuncan Sands CodeModel::Model CMM = 205026fa8782cd59f79ac6335e54a0d1cc882a0b626Jim Grosbach CodeModel::JITDefault); 20698a366d547772010e94609e4584489b3e5ce0043Bill Wendling 207f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// addModule - Add a Module to the list of modules that we can JIT from. 208f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// Note that this takes ownership of the Module: when the ExecutionEngine is 209f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// destroyed, it destroys the Module as well. 210f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin virtual void addModule(Module *M) { 211f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin Modules.push_back(M); 2122e40ae4de67ba37d02281d51e7dfd629205e1e30Chris Lattner } 213f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 21448dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar //===--------------------------------------------------------------------===// 2159f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner 2163574eca1b02600bac4e625297f4ecf745f4c4f32Micah Villmow const DataLayout *getDataLayout() const { return TD; } 2179f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner 218f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// removeModule - Remove a Module from the list of modules. Returns true if 219f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// M is found. 220f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin virtual bool removeModule(Module *M); 22160789e419e04c260e36af9a1add5ad316313e490Nate Begeman 222fe854034677f59baca1e38075e71f6efca247a03Chris Lattner /// FindFunctionNamed - Search all of the active modules to find the one that 223fe854034677f59baca1e38075e71f6efca247a03Chris Lattner /// defines FnName. This is very slow operation and shouldn't be used for 224fe854034677f59baca1e38075e71f6efca247a03Chris Lattner /// general code. 225fe854034677f59baca1e38075e71f6efca247a03Chris Lattner Function *FindFunctionNamed(const char *FnName); 226f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 227ff65e36be0f4fbe776ee6bb39b7ab14ebe3895ebChris Lattner /// runFunction - Execute the specified function with the specified arguments, 228ff65e36be0f4fbe776ee6bb39b7ab14ebe3895ebChris Lattner /// and return the result. 229ff65e36be0f4fbe776ee6bb39b7ab14ebe3895ebChris Lattner virtual GenericValue runFunction(Function *F, 230ff65e36be0f4fbe776ee6bb39b7ab14ebe3895ebChris Lattner const std::vector<GenericValue> &ArgValues) = 0; 231ff65e36be0f4fbe776ee6bb39b7ab14ebe3895ebChris Lattner 23245a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// getPointerToNamedFunction - This method returns the address of the 23345a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// specified function by using the dlsym function call. As such it is only 23445a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// useful for resolving library symbols, not code generated symbols. 23545a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// 23645a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// If AbortOnFailure is false and no function with the given name is 23745a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// found, this function silently returns a null pointer. Otherwise, 23845a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// it prints a message to stderr and aborts. 23945a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev /// 24045a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev virtual void *getPointerToNamedFunction(const std::string &Name, 24145a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev bool AbortOnFailure = true) = 0; 24245a93d6eb4c55876e94f91b471657f23fe2149aaDanil Malyshev 243020f4e861a9a32059f76377e787703c92ba55a98Jim Grosbach /// mapSectionAddress - map a section to its target address space value. 244020f4e861a9a32059f76377e787703c92ba55a98Jim Grosbach /// Map the address of a JIT section as returned from the memory manager 245020f4e861a9a32059f76377e787703c92ba55a98Jim Grosbach /// to the address in the target process as the running code will see it. 246020f4e861a9a32059f76377e787703c92ba55a98Jim Grosbach /// This is the address which will be used for relocation resolution. 247e940c1bb6c976539f07d6f440aeaacf7c25e1ddcJim Grosbach virtual void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress) { 24850bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper llvm_unreachable("Re-mapping of section addresses not supported with this " 24950bee42b54cd9aec5f49566307df2b0cf23afcf6Craig Topper "EE!"); 250020f4e861a9a32059f76377e787703c92ba55a98Jim Grosbach } 251020f4e861a9a32059f76377e787703c92ba55a98Jim Grosbach 2529ca6cdaee91fddcd3ea57dedcd624c14c7a40f65Chris Lattner /// runStaticConstructorsDestructors - This method is used to execute all of 25348dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// the static constructors or destructors for a program. 25448dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// 25548dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// \param isDtors - Run the destructors instead of constructors. 2569ca6cdaee91fddcd3ea57dedcd624c14c7a40f65Chris Lattner void runStaticConstructorsDestructors(bool isDtors); 25748dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar 25818314dc741ab7dc4db02b199af77f43bd8551fd2Evan Cheng /// runStaticConstructorsDestructors - This method is used to execute all of 25948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// the static constructors or destructors for a particular module. 26048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// 26148dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// \param isDtors - Run the destructors instead of constructors. 26218314dc741ab7dc4db02b199af77f43bd8551fd2Evan Cheng void runStaticConstructorsDestructors(Module *module, bool isDtors); 263f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 264f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 265e5dbbf2bddf7fc28d9f63a5e978af12184c80adaChris Lattner /// runFunctionAsMain - This is a helper function which wraps runFunction to 266e5dbbf2bddf7fc28d9f63a5e978af12184c80adaChris Lattner /// handle the common task of starting up main with the specified argc, argv, 267e5dbbf2bddf7fc28d9f63a5e978af12184c80adaChris Lattner /// and envp parameters. 268e5dbbf2bddf7fc28d9f63a5e978af12184c80adaChris Lattner int runFunctionAsMain(Function *Fn, const std::vector<std::string> &argv, 269e5dbbf2bddf7fc28d9f63a5e978af12184c80adaChris Lattner const char * const * envp); 270e5dbbf2bddf7fc28d9f63a5e978af12184c80adaChris Lattner 271e5dbbf2bddf7fc28d9f63a5e978af12184c80adaChris Lattner 272683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner /// addGlobalMapping - Tell the execution engine that the specified global is 273683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner /// at the specified location. This is used internally as functions are JIT'd 274683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner /// and as global variables are laid out in memory. It can and should also be 275683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner /// used by clients of the EE that want to have an LLVM global overlay 2764c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin /// existing data in memory. Mappings are automatically removed when their 2774c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin /// GlobalValue is destroyed. 278683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner void addGlobalMapping(const GlobalValue *GV, void *Addr); 279f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 28048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// clearAllGlobalMappings - Clear all global mappings and start over again, 28148dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// for use in dynamic compilation scenarios to move globals. 282683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner void clearAllGlobalMappings(); 283f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 284f049e07eb8930214941c72f8e4409df394de1567Nate Begeman /// clearGlobalMappingsFromModule - Clear all global mappings that came from a 285f049e07eb8930214941c72f8e4409df394de1567Nate Begeman /// particular module, because it has been removed from the JIT. 286f049e07eb8930214941c72f8e4409df394de1567Nate Begeman void clearGlobalMappingsFromModule(Module *M); 287f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 288f5feaf4fe381476b0ea567d7837c64b6590133e9Chris Lattner /// updateGlobalMapping - Replace an existing mapping for GV with a new 289683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner /// address. This updates both maps as required. If "Addr" is null, the 290f4cc3096fd893cdef5b5c2664ebff8c13a07ad51Chris Lattner /// entry for the global is removed from the mappings. This returns the old 291f4cc3096fd893cdef5b5c2664ebff8c13a07ad51Chris Lattner /// value of the pointer, or null if it was not in the map. 292f4cc3096fd893cdef5b5c2664ebff8c13a07ad51Chris Lattner void *updateGlobalMapping(const GlobalValue *GV, void *Addr); 293f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 294895be4bae2c4f9a2fd2234f0329f618274e67eabChris Lattner /// getPointerToGlobalIfAvailable - This returns the address of the specified 295683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner /// global value if it is has already been codegen'd, otherwise it returns 296683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner /// null. 297683d1bb712d8f8fc2d727a160da029c9cf40a423Chris Lattner void *getPointerToGlobalIfAvailable(const GlobalValue *GV); 29870bca51f92871c7f9d3eac9ab68292c149fab53cChris Lattner 299895be4bae2c4f9a2fd2234f0329f618274e67eabChris Lattner /// getPointerToGlobal - This returns the address of the specified global 30048dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// value. This may involve code generation if it's a function. 301bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner void *getPointerToGlobal(const GlobalValue *GV); 302bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner 303895be4bae2c4f9a2fd2234f0329f618274e67eabChris Lattner /// getPointerToFunction - The different EE's represent function bodies in 304895be4bae2c4f9a2fd2234f0329f618274e67eabChris Lattner /// different ways. They should each implement this to say what a function 3054c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin /// pointer should look like. When F is destroyed, the ExecutionEngine will 3067a9034c4db248fe8b8cb82762881b51b221988d3Jeffrey Yasskin /// remove its global mapping and free any machine code. Be sure no threads 3077a9034c4db248fe8b8cb82762881b51b221988d3Jeffrey Yasskin /// are running inside F when that happens. 308fb0ef2e82cb2e80983c097100ae168af68ee8e7bBrian Gaeke virtual void *getPointerToFunction(Function *F) = 0; 309bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner 310f32a6a3091e0b01d17926f4b1cf78972854b8cb5Chris Lattner /// getPointerToBasicBlock - The different EE's represent basic blocks in 311f32a6a3091e0b01d17926f4b1cf78972854b8cb5Chris Lattner /// different ways. Return the representation for a blockaddress of the 312f32a6a3091e0b01d17926f4b1cf78972854b8cb5Chris Lattner /// specified block. 313f32a6a3091e0b01d17926f4b1cf78972854b8cb5Chris Lattner virtual void *getPointerToBasicBlock(BasicBlock *BB) = 0; 314f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 315895be4bae2c4f9a2fd2234f0329f618274e67eabChris Lattner /// getPointerToFunctionOrStub - If the specified function has been 316895be4bae2c4f9a2fd2234f0329f618274e67eabChris Lattner /// code-gen'd, return a pointer to the function. If not, compile it, or use 3174c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin /// a stub to implement lazy compilation if available. See 3184c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin /// getPointerToFunction for the requirements on destroying F. 31918cb4c3c747ac2439ca9fb1218edd8993df69d7aChris Lattner virtual void *getPointerToFunctionOrStub(Function *F) { 32018cb4c3c747ac2439ca9fb1218edd8993df69d7aChris Lattner // Default implementation, just codegen the function. 32118cb4c3c747ac2439ca9fb1218edd8993df69d7aChris Lattner return getPointerToFunction(F); 32218cb4c3c747ac2439ca9fb1218edd8993df69d7aChris Lattner } 32318cb4c3c747ac2439ca9fb1218edd8993df69d7aChris Lattner 324b3a847db0b991d3210706a2580428fdc2b6bf037Argyrios Kyrtzidis // The JIT overrides a version that actually does this. 3255e0644c73e0415e85c035ad1306a86554dd26df7Bill Wendling virtual void runJITOnFunction(Function *, MachineCodeInfo * = 0) { } 326b3a847db0b991d3210706a2580428fdc2b6bf037Argyrios Kyrtzidis 327c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// getGlobalValueAtAddress - Return the LLVM global value object that starts 328c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// at the specified address. 329c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner /// 330c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner const GlobalValue *getGlobalValueAtAddress(void *Addr); 331c8a07d7378699b8d11ce2a1549b984d84706da19Chris Lattner 33248dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// StoreValueToMemory - Stores the data in Val of type Ty at address Ptr. 33348dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// Ptr is the address of the memory at which to store Val, cast to 33448dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// GenericValue *. It is not a pointer to a GenericValue containing the 33548dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// address at which to store Val. 336f4cc3096fd893cdef5b5c2664ebff8c13a07ad51Chris Lattner void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, 337db125cfaf57cc83e7dd7453de2d509bc8efd0e5eChris Lattner Type *Ty); 33848dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar 33929794cba810ec249a9ede5ea77333a71579fd182Brian Gaeke void InitializeMemory(const Constant *Init, void *Addr); 34029794cba810ec249a9ede5ea77333a71579fd182Brian Gaeke 34148dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// recompileAndRelinkFunction - This method is used to force a function which 34248dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// has already been compiled to be compiled again, possibly after it has been 34348dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// modified. Then the entry to the old copy is overwritten with a branch to 34448dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// the new copy. If there was no old copy, this acts just like 34548dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// VM::getPointerToFunction(). 34618cb4c3c747ac2439ca9fb1218edd8993df69d7aChris Lattner virtual void *recompileAndRelinkFunction(Function *F) = 0; 34718cb4c3c747ac2439ca9fb1218edd8993df69d7aChris Lattner 348e81aaf238c32dbc34274ede09fb16aa78dae9f53Misha Brukman /// freeMachineCodeForFunction - Release memory in the ExecutionEngine 349e81aaf238c32dbc34274ede09fb16aa78dae9f53Misha Brukman /// corresponding to the machine code emitted to execute this function, useful 350e81aaf238c32dbc34274ede09fb16aa78dae9f53Misha Brukman /// for garbage-collecting generated code. 351e81aaf238c32dbc34274ede09fb16aa78dae9f53Misha Brukman virtual void freeMachineCodeForFunction(Function *F) = 0; 352e81aaf238c32dbc34274ede09fb16aa78dae9f53Misha Brukman 3531514b5b334c72e1e190fe1ce2bce7bf7d8a91c1aChris Lattner /// getOrEmitGlobalVariable - Return the address of the specified global 3541514b5b334c72e1e190fe1ce2bce7bf7d8a91c1aChris Lattner /// variable, possibly emitting it to memory if needed. This is used by the 3554c5b23b24f230607fa18a162519875a91a5e89e0Jeffrey Yasskin /// Emitter. 3561514b5b334c72e1e190fe1ce2bce7bf7d8a91c1aChris Lattner virtual void *getOrEmitGlobalVariable(const GlobalVariable *GV) { 35772ea0c9ffaa1700730c8ce36e9b73aef4b914988Galina Kistanova return getPointerToGlobal((const GlobalValue *)GV); 3581514b5b334c72e1e190fe1ce2bce7bf7d8a91c1aChris Lattner } 359df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskin 360df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskin /// Registers a listener to be called back on various events within 361df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskin /// the JIT. See JITEventListener.h for more details. Does not 362df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskin /// take ownership of the argument. The argument may be NULL, in 363df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskin /// which case these functions do nothing. 364df225c0253aa987830fbd3dfcb5d9f8f7f973336Bill Wendling virtual void RegisterJITEventListener(JITEventListener *) {} 365df225c0253aa987830fbd3dfcb5d9f8f7f973336Bill Wendling virtual void UnregisterJITEventListener(JITEventListener *) {} 366df5a7daff9c7664bff8b713e8ed5155319bc6041Jeffrey Yasskin 36718fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin /// DisableLazyCompilation - When lazy compilation is off (the default), the 368dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// JIT will eagerly compile every function reachable from the argument to 369dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// getPointerToFunction. If lazy compilation is turned on, the JIT will only 370dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// compile the one function and emit stubs to compile the rest when they're 371dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// first called. If lazy compilation is turned off again while some lazy 372dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// stubs are still around, and one of those stubs is called, the program will 373dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// abort. 374dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// 375dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// In order to safely compile lazily in a threaded program, the user must 376dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// ensure that 1) only one thread at a time can call any particular lazy 377dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// stub, and 2) any thread modifying LLVM IR must hold the JIT's lock 378dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// (ExecutionEngine::lock) or otherwise ensure that no other thread calls a 379dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin /// lazy stub. See http://llvm.org/PR5184 for details. 38018fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin void DisableLazyCompilation(bool Disabled = true) { 38118fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin CompilingLazily = !Disabled; 3821c1a44699049cf56713a46ccaef7c747e4a888a3Chris Lattner } 383dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin bool isCompilingLazily() const { 384dc85724f703bddf6988b6b3f20203beab775f32bJeffrey Yasskin return CompilingLazily; 3851c1a44699049cf56713a46ccaef7c747e4a888a3Chris Lattner } 38618fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin // Deprecated in favor of isCompilingLazily (to reduce double-negatives). 38718fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin // Remove this in LLVM 2.8. 38818fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin bool isLazyCompilationDisabled() const { 38918fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin return !CompilingLazily; 39018fec73e29d68b9c7473720507f51de39b0873b1Jeffrey Yasskin } 391446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng 39277f86ad08775e0ed2a704ef09ffff3dbd6e04583Evan Cheng /// DisableGVCompilation - If called, the JIT will abort if it's asked to 39377f86ad08775e0ed2a704ef09ffff3dbd6e04583Evan Cheng /// allocate space and populate a GlobalVariable that is not internal to 39477f86ad08775e0ed2a704ef09ffff3dbd6e04583Evan Cheng /// the module. 395446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng void DisableGVCompilation(bool Disabled = true) { 396446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng GVCompilationDisabled = Disabled; 397446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng } 398446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng bool isGVCompilationDisabled() const { 399446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng return GVCompilationDisabled; 400446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng } 401446531e7bb4355117b070493ca8e81e4b123ef18Evan Cheng 402e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner /// DisableSymbolSearching - If called, the JIT will not try to lookup unknown 403e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner /// symbols with dlsym. A client can still use InstallLazyFunctionCreator to 404e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner /// resolve symbols in a custom way. 405e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner void DisableSymbolSearching(bool Disabled = true) { 406e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner SymbolSearchingDisabled = Disabled; 407e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner } 408e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner bool isSymbolSearchingDisabled() const { 409e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner return SymbolSearchingDisabled; 410e846db667529eeeae531ce3b7382e18888d1eba0Chris Lattner } 4116f348e458660063a40052b208bab96895c822877Jeffrey Yasskin 412d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner /// InstallLazyFunctionCreator - If an unknown function is needed, the 413d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner /// specified function pointer is invoked to create it. If it returns null, 414d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner /// the JIT will abort. 415d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner void InstallLazyFunctionCreator(void* (*P)(const std::string &)) { 416d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner LazyFunctionCreator = P; 417d958a5a9feea7239a73c2068f43f237db550f46eChris Lattner } 418f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 419afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray /// InstallExceptionTableRegister - The JIT will use the given function 420afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray /// to register the exception tables it generates. 421b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands void InstallExceptionTableRegister(EERegisterFn F) { 422afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray ExceptionTableRegister = F; 423afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray } 424b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands void InstallExceptionTableDeregister(EERegisterFn F) { 425b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands ExceptionTableDeregister = F; 426b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands } 427f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach 42848dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// RegisterTable - Registers the given pointer as an exception table. It 42948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// uses the ExceptionTableRegister function. 430515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher void RegisterTable(const Function *fn, void* res) { 431b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands if (ExceptionTableRegister) { 432afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray ExceptionTableRegister(res); 433515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher AllExceptionTables[fn] = res; 434515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher } 435515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher } 436515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher 437f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach /// DeregisterTable - Deregisters the exception frame previously registered 438f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach /// for the given function. 439515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher void DeregisterTable(const Function *Fn) { 440515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher if (ExceptionTableDeregister) { 441f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach DenseMap<const Function*, void*>::iterator frame = 442f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach AllExceptionTables.find(Fn); 443515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher if(frame != AllExceptionTables.end()) { 444515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher ExceptionTableDeregister(frame->second); 445515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher AllExceptionTables.erase(frame); 446515c67ee77f8d9c417efc0fe04615d269bfb70e4Eric Christopher } 447b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands } 448afe6c2b001a924cd74bd0aacfed5984d9af004b0Nicolas Geoffray } 4491514b5b334c72e1e190fe1ce2bce7bf7d8a91c1aChris Lattner 450b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands /// DeregisterAllTables - Deregisters all previously registered pointers to an 45148dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbar /// exception tables. It uses the ExceptionTableoDeregister function. 452b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands void DeregisterAllTables(); 453b35fd448cea32da671ecd3ecaad3cc637598c6e0Duncan Sands 45456adf152f6354a9b5609e059050fd2315ad5960cChris Lattnerprotected: 455f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin explicit ExecutionEngine(Module *M); 4569f2f142d255bc96f109dd5c6524a485937b1f3a1Chris Lattner 457bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner void emitGlobals(); 4583ddc05bdde6ed65f93340ea467d362e80c0ceb9cChris Lattner 4591514b5b334c72e1e190fe1ce2bce7bf7d8a91c1aChris Lattner void EmitGlobalVariable(const GlobalVariable *GV); 4603ddc05bdde6ed65f93340ea467d362e80c0ceb9cChris Lattner 461bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner GenericValue getConstantValue(const Constant *C); 462f5b23368d27ef7dd44b2c45b5c08812ac99c7661Jim Grosbach void LoadValueFromMemory(GenericValue &Result, GenericValue *Ptr, 463db125cfaf57cc83e7dd7453de2d509bc8efd0e5eChris Lattner Type *Ty); 464bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner}; 465bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner 4664b1511b027ce0b648b3379f2891816c25b46f515Reid Klecknernamespace EngineKind { 4674b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner // These are actually bitmasks that get or-ed together. 4684b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner enum Kind { 4694b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner JIT = 0x1, 4704b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner Interpreter = 0x2 4714b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner }; 4724b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner const static Kind Either = (Kind)(JIT | Interpreter); 4734b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner} 4744b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 4754b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner/// EngineBuilder - Builder class for ExecutionEngines. Use this by 4764b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner/// stack-allocating a builder, chaining the various set* methods, and 4774b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner/// terminating it with a .create() call. 4784b1511b027ce0b648b3379f2891816c25b46f515Reid Klecknerclass EngineBuilder { 47948dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbarprivate: 480f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin Module *M; 4814b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner EngineKind::Kind WhichEngine; 4824b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner std::string *ErrorStr; 4834b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner CodeGenOpt::Level OptLevel; 4844b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner JITMemoryManager *JMM; 4854b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner bool AllocateGVsWithCode; 486d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne TargetOptions Options; 487439661395fd2a2a832dba01c65bc88718528313cEvan Cheng Reloc::Model RelocModel; 48888b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher CodeModel::Model CMModel; 4894688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin std::string MArch; 4904688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin std::string MCPU; 4914688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin SmallVector<std::string, 4> MAttrs; 4926d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar bool UseMCJIT; 4934b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 4944b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// InitEngine - Does the common initialization of default options. 4954b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner void InitEngine() { 4964b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner WhichEngine = EngineKind::Either; 4974b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner ErrorStr = NULL; 4984b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner OptLevel = CodeGenOpt::Default; 4994b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner JMM = NULL; 500d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne Options = TargetOptions(); 5014b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner AllocateGVsWithCode = false; 502439661395fd2a2a832dba01c65bc88718528313cEvan Cheng RelocModel = Reloc::Default; 50334ad6db8b958fdc0d38e122edf753b5326e69b03Evan Cheng CMModel = CodeModel::JITDefault; 5046d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar UseMCJIT = false; 5054b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner } 5064b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 50748dd875be12006060260526e4a1df0bae48dd5c9Daniel Dunbarpublic: 5084b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// EngineBuilder - Constructor for EngineBuilder. If create() is called and 509f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin /// is successful, the created engine takes ownership of the module. 510f0356fe140af1a30587b9a86bcfb1b2c51b8ce20Jeffrey Yasskin EngineBuilder(Module *m) : M(m) { 5114b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner InitEngine(); 5124b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner } 5134b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 5144b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// setEngineKind - Controls whether the user wants the interpreter, the JIT, 5154b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// or whichever engine works. This option defaults to EngineKind::Either. 5164b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner EngineBuilder &setEngineKind(EngineKind::Kind w) { 5174b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner WhichEngine = w; 5184b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner return *this; 5194b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner } 5204b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 5214b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// setJITMemoryManager - Sets the memory manager to use. This allows 5224b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// clients to customize their memory allocation policies. If create() is 5234b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// called and is successful, the created engine takes ownership of the 5244b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// memory manager. This option defaults to NULL. 5254b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) { 5264b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner JMM = jmm; 5274b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner return *this; 5284b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner } 5294b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 5304b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// setErrorStr - Set the error string to write to on error. This option 5314b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// defaults to NULL. 5324b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner EngineBuilder &setErrorStr(std::string *e) { 5334b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner ErrorStr = e; 5344b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner return *this; 5354b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner } 5364b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 5374b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// setOptLevel - Set the optimization level for the JIT. This option 5384b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// defaults to CodeGenOpt::Default. 5394b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner EngineBuilder &setOptLevel(CodeGenOpt::Level l) { 5404b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner OptLevel = l; 5414b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner return *this; 5424b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner } 5434b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 544d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne /// setTargetOptions - Set the target options that the ExecutionEngine 545d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne /// target is using. Defaults to TargetOptions(). 546d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne EngineBuilder &setTargetOptions(const TargetOptions &Opts) { 547d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne Options = Opts; 548d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne return *this; 549d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne } 550d40e103ea5bca8a223fc8261b3322b9454e9af12Peter Collingbourne 551439661395fd2a2a832dba01c65bc88718528313cEvan Cheng /// setRelocationModel - Set the relocation model that the ExecutionEngine 552439661395fd2a2a832dba01c65bc88718528313cEvan Cheng /// target is using. Defaults to target specific default "Reloc::Default". 553439661395fd2a2a832dba01c65bc88718528313cEvan Cheng EngineBuilder &setRelocationModel(Reloc::Model RM) { 554439661395fd2a2a832dba01c65bc88718528313cEvan Cheng RelocModel = RM; 555439661395fd2a2a832dba01c65bc88718528313cEvan Cheng return *this; 556439661395fd2a2a832dba01c65bc88718528313cEvan Cheng } 557439661395fd2a2a832dba01c65bc88718528313cEvan Cheng 55888b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher /// setCodeModel - Set the CodeModel that the ExecutionEngine target 55934ad6db8b958fdc0d38e122edf753b5326e69b03Evan Cheng /// data is using. Defaults to target specific default 56034ad6db8b958fdc0d38e122edf753b5326e69b03Evan Cheng /// "CodeModel::JITDefault". 56188b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher EngineBuilder &setCodeModel(CodeModel::Model M) { 56288b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher CMModel = M; 56388b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher return *this; 56488b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher } 56588b5aca20a6dd0a8b15ff620bdee59aae567d245Eric Christopher 5664b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// setAllocateGVsWithCode - Sets whether global values should be allocated 5674b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// into the same buffer as code. For most applications this should be set 5684b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// to false. Allocating globals with code breaks freeMachineCodeForFunction 5694b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// and is probably unsafe and bad for performance. However, we have clients 5704b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// who depend on this behavior, so we must support it. This option defaults 5714b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// to false so that users of the new API can safely use the new memory 5724b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner /// manager and free machine code. 5734b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner EngineBuilder &setAllocateGVsWithCode(bool a) { 5744b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner AllocateGVsWithCode = a; 5754b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner return *this; 5764b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner } 5774b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 5784688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin /// setMArch - Override the architecture set by the Module's triple. 5794688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin EngineBuilder &setMArch(StringRef march) { 5804688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin MArch.assign(march.begin(), march.end()); 5814688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin return *this; 5824688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin } 5834688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin 5844688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin /// setMCPU - Target a specific cpu type. 5854688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin EngineBuilder &setMCPU(StringRef mcpu) { 5864688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin MCPU.assign(mcpu.begin(), mcpu.end()); 5874688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin return *this; 5884688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin } 5894688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin 5906d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar /// setUseMCJIT - Set whether the MC-JIT implementation should be used 5916d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar /// (experimental). 592714b34fc24d5df02aff01bd64eb80e5945d663acJim Grosbach EngineBuilder &setUseMCJIT(bool Value) { 5936d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar UseMCJIT = Value; 594714b34fc24d5df02aff01bd64eb80e5945d663acJim Grosbach return *this; 5956d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar } 5966d135972bf4e7fdc4de6b0538d6a3b91a06e3a5dDaniel Dunbar 5974688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin /// setMAttrs - Set cpu-specific attributes. 5984688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin template<typename StringSequence> 5994688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin EngineBuilder &setMAttrs(const StringSequence &mattrs) { 6004688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin MAttrs.clear(); 6014688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin MAttrs.append(mattrs.begin(), mattrs.end()); 6024688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin return *this; 6034688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin } 6044688261c20735f5ead2f08695acdeb727db31894Jeffrey Yasskin 6058e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson TargetMachine *selectTarget(); 6068e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson 6072ea29ba2a8ddd7ba4b946eb754f1a39304d9fc09Dylan Noblesmith /// selectTarget - Pick a target either via -march or by guessing the native 6082ea29ba2a8ddd7ba4b946eb754f1a39304d9fc09Dylan Noblesmith /// arch. Add any CPU features specified via -mcpu or -mattr. 6098e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson TargetMachine *selectTarget(const Triple &TargetTriple, 6108e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson StringRef MArch, 6118e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson StringRef MCPU, 6128e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson const SmallVectorImpl<std::string>& MAttrs); 6138e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson 6148e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson ExecutionEngine *create() { 6158e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson return create(selectTarget()); 6168e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson } 6178e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson 6188e1fc56b2496270d1d6040cb648eef5d5aeb6079Owen Anderson ExecutionEngine *create(TargetMachine *TM); 6194b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner}; 6204b1511b027ce0b648b3379f2891816c25b46f515Reid Kleckner 621d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace 622d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 623bd199fb1148b9e16c4e6f3d0ee386c2505a55b71Chris Lattner#endif 624