diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-01 16:58:40 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-01 16:58:40 +0000 |
commit | 8b477ed579794ba6d76915d56b3f448a7dd20120 (patch) | |
tree | 70d3be97f6ecf1ab7962e6cfafd113f2f7ce2579 /include/llvm | |
parent | 4fb75e542539153acaf31d9221845a7d0feccbf6 (diff) | |
download | external_llvm-8b477ed579794ba6d76915d56b3f448a7dd20120.zip external_llvm-8b477ed579794ba6d76915d56b3f448a7dd20120.tar.gz external_llvm-8b477ed579794ba6d76915d56b3f448a7dd20120.tar.bz2 |
Add a pointer to the owning LLVMContext to Module. This requires threading LLVMContext through a lot
of the bitcode reader and ASM parser APIs, as well as supporting it in all of the tools.
Patches for Clang and LLVM-GCC to follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Assembly/Parser.h | 7 | ||||
-rw-r--r-- | include/llvm/Bitcode/Archive.h | 9 | ||||
-rw-r--r-- | include/llvm/Bitcode/ReaderWriter.h | 5 | ||||
-rw-r--r-- | include/llvm/Debugger/Debugger.h | 3 | ||||
-rw-r--r-- | include/llvm/LinkAllVMCore.h | 2 | ||||
-rw-r--r-- | include/llvm/Linker.h | 3 | ||||
-rw-r--r-- | include/llvm/Module.h | 9 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/Cloning.h | 1 |
8 files changed, 31 insertions, 8 deletions
diff --git a/include/llvm/Assembly/Parser.h b/include/llvm/Assembly/Parser.h index e4a38e4..2a5bac7 100644 --- a/include/llvm/Assembly/Parser.h +++ b/include/llvm/Assembly/Parser.h @@ -21,6 +21,7 @@ namespace llvm { class Module; class ParseError; class raw_ostream; +class LLVMContext; /// This function is the main interface to the LLVM Assembly Parser. It parses /// an ASCII file that (presumably) contains LLVM Assembly code. It returns a @@ -30,7 +31,8 @@ class raw_ostream; /// @brief Parse LLVM Assembly from a file Module *ParseAssemblyFile( const std::string &Filename, ///< The name of the file to parse - ParseError &Error ///< If not null, an object to return errors in. + ParseError &Error, ///< If not null, an object to return errors in. + LLVMContext* Context ///< Context in which to allocate globals info. ); /// The function is a secondary interface to the LLVM Assembly Parser. It parses @@ -42,7 +44,8 @@ Module *ParseAssemblyFile( Module *ParseAssemblyString( const char *AsmString, ///< The string containing assembly Module *M, ///< A module to add the assembly too. - ParseError &Error ///< If not null, an object to return errors in. + ParseError &Error, ///< If not null, an object to return errors in. + LLVMContext* Context ); //===------------------------------------------------------------------------=== diff --git a/include/llvm/Bitcode/Archive.h b/include/llvm/Bitcode/Archive.h index a3631ac..c188df8 100644 --- a/include/llvm/Bitcode/Archive.h +++ b/include/llvm/Bitcode/Archive.h @@ -32,6 +32,7 @@ class ModuleProvider; // From VMCore class Module; // From VMCore class Archive; // Declared below class ArchiveMemberHeader; // Internal implementation class +class LLVMContext; // Global data /// This class is the main class manipulated by users of the Archive class. It /// holds information about one member of the Archive. It is also the element @@ -278,7 +279,8 @@ class Archive { /// @returns An Archive* that represents the new archive file. /// @brief Create an empty Archive. static Archive* CreateEmpty( - const sys::Path& Filename ///< Name of the archive to (eventually) create. + const sys::Path& Filename,///< Name of the archive to (eventually) create. + LLVMContext* C ///< Context to use for global information ); /// Open an existing archive and load its contents in preparation for @@ -289,6 +291,7 @@ class Archive { /// @brief Open and load an archive file static Archive* OpenAndLoad( const sys::Path& filePath, ///< The file path to open and load + LLVMContext* C, ///< The context to use for global information std::string* ErrorMessage ///< An optional error string ); @@ -310,6 +313,7 @@ class Archive { /// @brief Open an existing archive and load its symbols. static Archive* OpenAndLoadSymbols( const sys::Path& Filename, ///< Name of the archive file to open + LLVMContext* C, ///< The context to use for global info std::string* ErrorMessage=0 ///< An optional error string ); @@ -449,7 +453,7 @@ class Archive { protected: /// @brief Construct an Archive for \p filename and optionally map it /// into memory. - explicit Archive(const sys::Path& filename); + explicit Archive(const sys::Path& filename, LLVMContext* C); /// @param data The symbol table data to be parsed /// @param len The length of the symbol table data @@ -530,6 +534,7 @@ class Archive { unsigned firstFileOffset; ///< Offset to first normal file. ModuleMap modules; ///< The modules loaded via symbol lookup. ArchiveMember* foreignST; ///< This holds the foreign symbol table. + LLVMContext* Context; ///< This holds global data. /// @} /// @name Hidden /// @{ diff --git a/include/llvm/Bitcode/ReaderWriter.h b/include/llvm/Bitcode/ReaderWriter.h index abdd5d3..a781187 100644 --- a/include/llvm/Bitcode/ReaderWriter.h +++ b/include/llvm/Bitcode/ReaderWriter.h @@ -23,6 +23,7 @@ namespace llvm { class MemoryBuffer; class ModulePass; class BitstreamWriter; + class LLVMContext; class raw_ostream; /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer @@ -31,12 +32,14 @@ namespace llvm { /// error, this returns null, *does not* take ownership of Buffer, and fills /// in *ErrMsg with an error description if ErrMsg is non-null. ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer, + LLVMContext* Context, std::string *ErrMsg = 0); /// ParseBitcodeFile - Read the specified bitcode file, returning the module. /// If an error occurs, this returns null and fills in *ErrMsg if it is /// non-null. This method *never* takes ownership of Buffer. - Module *ParseBitcodeFile(MemoryBuffer *Buffer, std::string *ErrMsg = 0); + Module *ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext* Context, + std::string *ErrMsg = 0); /// WriteBitcodeToFile - Write the specified module to the specified output /// stream. diff --git a/include/llvm/Debugger/Debugger.h b/include/llvm/Debugger/Debugger.h index 5b0b97a..ed04ed5 100644 --- a/include/llvm/Debugger/Debugger.h +++ b/include/llvm/Debugger/Debugger.h @@ -20,6 +20,7 @@ namespace llvm { class Module; class InferiorProcess; + class LLVMContext; /// Debugger class - This class implements the LLVM source-level debugger. /// This allows clients to handle the user IO processing without having to @@ -95,7 +96,7 @@ namespace llvm { /// the PATH for the specified program, loading it when found. If the /// specified program cannot be found, an exception is thrown to indicate /// the error. - void loadProgram(const std::string &Path); + void loadProgram(const std::string &Path, LLVMContext* Context); /// unloadProgram - If a program is running, kill it, then unload all traces /// of the current program. If no program is loaded, this method silently diff --git a/include/llvm/LinkAllVMCore.h b/include/llvm/LinkAllVMCore.h index 4c428a0..3c4b9c4 100644 --- a/include/llvm/LinkAllVMCore.h +++ b/include/llvm/LinkAllVMCore.h @@ -44,7 +44,7 @@ namespace { // to know that getenv() never returns -1, this will do the job. if (std::getenv("bar") != (char*) -1) return; - llvm::Module* M = new llvm::Module(""); + llvm::Module* M = new llvm::Module("", 0); (void)new llvm::UnreachableInst(); (void) llvm::createVerifierPass(); (void) new llvm::Mangler(*M,""); diff --git a/include/llvm/Linker.h b/include/llvm/Linker.h index 884e872..8389dc7 100644 --- a/include/llvm/Linker.h +++ b/include/llvm/Linker.h @@ -21,6 +21,7 @@ namespace llvm { class Module; +class LLVMContext; /// This class provides the core functionality of linking in LLVM. It retains a /// Module object which is the composite of the modules and libraries linked @@ -66,6 +67,7 @@ class Linker { Linker( const std::string& progname, ///< name of tool running linker const std::string& modulename, ///< name of linker's end-result module + LLVMContext* C, ///< Context for global info unsigned Flags = 0 ///< ControlFlags (one or more |'d together) ); @@ -283,6 +285,7 @@ class Linker { /// @name Data /// @{ private: + LLVMContext* Context; ///< The context for global information Module* Composite; ///< The composite module linked together std::vector<sys::Path> LibPaths; ///< The library search paths unsigned Flags; ///< Flags to control optional behavior. diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 9c8607a..8370ffb 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -25,6 +25,7 @@ namespace llvm { class GlobalValueRefMap; // Used by ConstantVals.cpp class FunctionType; +class LLVMContext; template<> struct ilist_traits<Function> : public SymbolTableListTraits<Function, Module> { @@ -109,6 +110,8 @@ public: /// @name Member Variables /// @{ private: + LLVMContext* Context; ///< The LLVMContext from which types and + ///< constants are allocated. GlobalListType GlobalList; ///< The Global Variables in the module FunctionListType FunctionList; ///< The Functions in the module AliasListType AliasList; ///< The Aliases in the module @@ -128,7 +131,7 @@ private: public: /// The Module constructor. Note that there is no default constructor. You /// must provide a name for the module upon construction. - explicit Module(const std::string &ModuleID); + explicit Module(const std::string &ModuleID, LLVMContext* C); /// The module destructor. This will dropAllReferences. ~Module(); @@ -157,6 +160,10 @@ public: /// @returns PointerSize - an enumeration for the size of the target's pointer PointerSize getPointerSize() const; + /// Get the global data context. + /// @returns LLVMContext - a container for LLVM's global information + LLVMContext* getContext() const { return Context; } + /// Get any module-scope inline assembly blocks. /// @returns a string containing the module-scope inline assembly blocks. const std::string &getModuleInlineAsm() const { return GlobalScopeAsm; } diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h index 1e2bbaa..840d970 100644 --- a/include/llvm/Transforms/Utils/Cloning.h +++ b/include/llvm/Transforms/Utils/Cloning.h @@ -37,6 +37,7 @@ class Trace; class CallGraph; class TargetData; class LoopInfo; +class LLVMContext; template<class N> class LoopBase; typedef LoopBase<BasicBlock> Loop; |