| Owen Anderson | 2bc29dc | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 1 | //===-- llvm/LLVMContext.h - Class for managing "global" state --*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| Owen Anderson | 5217007 | 2009-06-30 17:06:46 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file declares LLVMContext, a container of "global" state in LLVM, such |
| 11 | // as the global type and constant uniquing tables. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| Owen Anderson | 2bc29dc | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 14 | |
| 15 | #ifndef LLVM_LLVMCONTEXT_H |
| 16 | #define LLVM_LLVMCONTEXT_H |
| 17 | |
| Owen Anderson | 2bc29dc | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 18 | namespace llvm { |
| 19 | |
| Benjamin Kramer | 12ddd40 | 2009-08-11 17:45:13 +0000 | [diff] [blame] | 20 | class LLVMContextImpl; |
| Chris Lattner | 0811347 | 2009-12-29 09:01:33 +0000 | [diff] [blame^] | 21 | class StringRef; |
| 22 | template <typename T> class SmallVectorImpl; |
| Dan Gohman | 82a47e9 | 2009-10-06 17:43:57 +0000 | [diff] [blame] | 23 | |
| Owen Anderson | 5217007 | 2009-06-30 17:06:46 +0000 | [diff] [blame] | 24 | /// This is an important class for using LLVM in a threaded context. It |
| 25 | /// (opaquely) owns and manages the core "global" data of LLVM's core |
| 26 | /// infrastructure, including the type and constant uniquing tables. |
| 27 | /// LLVMContext itself provides no locking guarantees, so you should be careful |
| 28 | /// to have one context per thread. |
| Benjamin Kramer | 12ddd40 | 2009-08-11 17:45:13 +0000 | [diff] [blame] | 29 | class LLVMContext { |
| Owen Anderson | 1d0be15 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 30 | // DO NOT IMPLEMENT |
| 31 | LLVMContext(LLVMContext&); |
| 32 | void operator=(LLVMContext&); |
| Dan Gohman | 82a47e9 | 2009-10-06 17:43:57 +0000 | [diff] [blame] | 33 | |
| Benjamin Kramer | 12ddd40 | 2009-08-11 17:45:13 +0000 | [diff] [blame] | 34 | public: |
| Chris Lattner | 0811347 | 2009-12-29 09:01:33 +0000 | [diff] [blame^] | 35 | LLVMContextImpl *const pImpl; |
| Owen Anderson | 2bc29dc | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 36 | LLVMContext(); |
| 37 | ~LLVMContext(); |
| Chris Lattner | 0811347 | 2009-12-29 09:01:33 +0000 | [diff] [blame^] | 38 | |
| 39 | /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. |
| 40 | /// This ID is uniqued across modules in the current LLVMContext. |
| 41 | unsigned getMDKindID(StringRef Name) const; |
| 42 | |
| 43 | /// getMDKindNames - Populate client supplied SmallVector with the name for |
| 44 | /// custom metadata IDs registered in this LLVMContext. ID #0 is not used, |
| 45 | /// so it is filled in as an empty string. |
| 46 | void getMDKindNames(SmallVectorImpl<StringRef> &Result) const; |
| Owen Anderson | 2bc29dc | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| Chris Lattner | 0811347 | 2009-12-29 09:01:33 +0000 | [diff] [blame^] | 49 | /// getGlobalContext - Returns a global context. This is for LLVM clients that |
| 50 | /// only care about operating on a single thread. |
| 51 | extern LLVMContext &getGlobalContext(); |
| Owen Anderson | db47ed0 | 2009-06-30 23:39:59 +0000 | [diff] [blame] | 52 | |
| Owen Anderson | 2bc29dc | 2009-06-30 00:48:55 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | #endif |