Push LLVMContext _back_ through IRBuilder.
[oota-llvm.git] / docs / tutorial / LangImpl4.html
index b956260628839b27aaf6f51cb56c368928b6c5a9..f08665d64cd47e44226d58f2c301581bb2c18b70 100644 (file)
@@ -87,7 +87,7 @@ entry:
 </pre>
 </div>
 
-Constant folding, as seen above, in particular, is a very common and very
+<p>Constant folding, as seen above, in particular, is a very common and very
 important optimization: so much so that many language implementors implement
 constant folding support in their AST representation.</p>
 
@@ -501,12 +501,18 @@ LLVM JIT and optimizer.  To build this example, use:
 </pre>
 </div>
 
+<p>
+If you are compiling this on Linux, make sure to add the "-rdynamic" option 
+as well.  This makes sure that the external functions are resolved properly 
+at runtime.</p>
+
 <p>Here is the code:</p>
 
 <div class="doc_code">
 <pre>
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
 #include "llvm/ModuleProvider.h"
 #include "llvm/PassManager.h"
@@ -856,14 +862,14 @@ static PrototypeAST *ParseExtern() {
 //===----------------------------------------------------------------------===//
 
 static Module *TheModule;
-static IRBuilder Builder;
+static IRBuilder&lt;&gt; Builder(getGlobalContext());
 static std::map&lt;std::string, Value*&gt; NamedValues;
 static FunctionPassManager *TheFPM;
 
 Value *ErrorV(const char *Str) { Error(Str); return 0; }
 
 Value *NumberExprAST::Codegen() {
-  return ConstantFP::get(Type::DoubleTy, APFloat(Val));
+  return ConstantFP::get(APFloat(Val));
 }
 
 Value *VariableExprAST::Codegen() {
@@ -1069,7 +1075,7 @@ int main() {
   getNextToken();
 
   // Make the module, which holds all the code.
-  TheModule = new Module("my cool jit");
+  TheModule = new Module("my cool jit", getGlobalContext());
   
   // Create the JIT.
   TheExecutionEngine = ExecutionEngine::create(TheModule);