diff options
author | Owen Anderson <resistor@mac.com> | 2009-08-19 17:58:52 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-08-19 17:58:52 +0000 |
commit | e0c951a5afe253c1e66b565e0d28b3dfe5d586a7 (patch) | |
tree | 826ac11b74f79a66e31b7fa9599fe2c0d981cebc /docs/ProgrammersManual.html | |
parent | 425d08c654c7893782b1215f9b2715bc1d90bd07 (diff) | |
download | external_llvm-e0c951a5afe253c1e66b565e0d28b3dfe5d586a7.zip external_llvm-e0c951a5afe253c1e66b565e0d28b3dfe5d586a7.tar.gz external_llvm-e0c951a5afe253c1e66b565e0d28b3dfe5d586a7.tar.bz2 |
Add a first stab at describing LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79435 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/ProgrammersManual.html')
-rw-r--r-- | docs/ProgrammersManual.html | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index e920cbb..eaed402 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -147,6 +147,7 @@ with another <tt>Value</tt></a> </li> </a></li> <li><a href="#shutdown">Ending execution with <tt>llvm_shutdown()</tt></a></li> <li><a href="#managedstatic">Lazy initialization with <tt>ManagedStatic</tt></a></li> + <li><a href="#llvmcontext">Achieving Isolation with <tt>LLVMContext</tt></a></li> </ul> </li> @@ -2402,6 +2403,50 @@ and only if you know what you're doing! </p> </div> +<!-- ======================================================================= --> +<div class="doc_subsection"> + <a name="llvmcontext">Achieving Isolation with <tt>LLVMContext</tt></a> +</div> + +<div class="doc_text"> +<p> +<tt>LLVMContext</tt> is an opaque class in the LLVM API which clients can use +to operate multiple, isolated instances of LLVM concurrently within the same +address space. For instance, in a hypothetical compile-server, the compilation +of an individual translation unit is conceptually independent from all the +others, and it would be desirable to be able to compile incoming translation +units concurrently on independent server threads. Fortunately, +<tt>LLVMContext</tt> exists to enable just this kind of scenario! +</p> + +<p> +Conceptually, <tt>LLVMContext</tt> provides isolation. Every LLVM entity +(<tt>Module</tt>s, <tt>Value</tt>s, <tt>Type</tt>s, <tt>Constant</tt>s, etc.) +in LLVM's in-memory IR belongs to an <tt>LLVMContext</tt>. Entities in +different contexts <em>cannot</em> interact with each other: <tt>Module</tt>s in +different contexts cannot be linked together, <tt>Function</tt>s cannot be added +to <tt>Module</tt>s in different contexts, etc. What this means is that is is +safe to compile on multiple threads simultaneously, as long as no two threads +operate on entities within the same context. +</p> + +<p> +In practice, very few places in the API require the explicit specification of a +<tt>LLVMContext</tt>, other than the <tt>Type</tt> creation/lookup APIs. +Because every <tt>Type</tt> carries a reference to its owning context, most +other entities can determine what context they belong to by looking at their +own <tt>Type</tt>. If you are adding new entities to LLVM IR, please try to +maintain this interface design. +</p> + +<p> +For clients that do <em>not</em> require the benefits of isolation, LLVM +provides a convenience API <tt>getGlobalContext()</tt>. This returns a global, +lazily initialized <tt>LLVMContext</tt> that may be used in situations where +isolation is not a concern. +</p> +</div> + <!-- *********************************************************************** --> <div class="doc_section"> <a name="advanced">Advanced Topics</a> |