/// the function. This is used for mutable variables etc.
static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
- LLVMBuilder TmpB(&TheFunction->getEntryBlock(),
- TheFunction->getEntryBlock().begin());
+ IRBuilder TmpB(&TheFunction->getEntryBlock(),
+ TheFunction->getEntryBlock().begin());
return TmpB.CreateAlloca(Type::DoubleTy, 0, VarName.c_str());
}
</pre>
</div>
-<p>This funny looking code creates an LLVMBuilder object that is pointing at
+<p>This funny looking code creates an IRBuilder object that is pointing at
the first instruction (.begin()) of the entry block. It then creates an alloca
with the expected name and returns it. Because all values in Kaleidoscope are
doubles, there is no need to pass in a type to use.</p>
#include "llvm/Analysis/Verifier.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/Scalar.h"
-#include "llvm/Support/LLVMBuilder.h"
+#include "llvm/Support/IRBuilder.h"
#include <cstdio>
#include <string>
#include <map>
//===----------------------------------------------------------------------===//
static Module *TheModule;
-static LLVMFoldingBuilder Builder;
+static IRBuilder Builder;
static std::map<std::string, AllocaInst*> NamedValues;
static FunctionPassManager *TheFPM;
/// the function. This is used for mutable variables etc.
static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
- LLVMBuilder TmpB(&TheFunction->getEntryBlock(),
- TheFunction->getEntryBlock().begin());
+ IRBuilder TmpB(&TheFunction->getEntryBlock(),
+ TheFunction->getEntryBlock().begin());
return TmpB.CreateAlloca(Type::DoubleTy, 0, VarName.c_str());
}
MainLoop();
TheFPM = 0;
- } // Free module provider and pass manager.
-
-
- // Print out all of the generated code.
- TheModule->dump();
+
+ // Print out all of the generated code.
+ TheModule->dump();
+
+ } // Free module provider (and thus the module) and pass manager.
+
return 0;
}
</pre>
</div>
+<a href="LangImpl8.html">Next: Conclusion and other useful LLVM tidbits</a>
</div>
<!-- *********************************************************************** -->