summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/BrainF/BrainF.cpp9
-rw-r--r--examples/BrainF/BrainF.h5
-rw-r--r--examples/BrainF/BrainFDriver.cpp4
-rw-r--r--examples/Fibonacci/fibonacci.cpp5
-rw-r--r--examples/HowToUseJIT/HowToUseJIT.cpp5
-rw-r--r--examples/Kaleidoscope/toy.cpp4
-rw-r--r--examples/ModuleMaker/ModuleMaker.cpp5
-rw-r--r--examples/ParallelJIT/ParallelJIT.cpp4
8 files changed, 29 insertions, 12 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp
index 32a14c4d53..0caff13e81 100644
--- a/examples/BrainF/BrainF.cpp
+++ b/examples/BrainF/BrainF.cpp
@@ -36,19 +36,20 @@ const char *BrainF::headreg = "head";
const char *BrainF::label = "brainf";
const char *BrainF::testreg = "test";
-Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf) {
+Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
+ LLVMContext* Context) {
in = in1;
memtotal = mem;
comflag = cf;
- header();
+ header(Context);
readloop(0, 0, 0);
delete builder;
return module;
}
-void BrainF::header() {
- module = new Module("BrainF");
+void BrainF::header(LLVMContext* C) {
+ module = new Module("BrainF", C);
//Function prototypes
diff --git a/examples/BrainF/BrainF.h b/examples/BrainF/BrainF.h
index 06c00ae4df..d0fb1b1de0 100644
--- a/examples/BrainF/BrainF.h
+++ b/examples/BrainF/BrainF.h
@@ -15,6 +15,7 @@
#ifndef BRAINF_H
#define BRAINF_H
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Support/IRBuilder.h"
@@ -38,7 +39,7 @@ class BrainF {
/// containing the resulting code.
/// On error, it calls abort.
/// The caller must delete the returned module.
- Module *parse(std::istream *in1, int mem, CompileFlags cf);
+ Module *parse(std::istream *in1, int mem, CompileFlags cf, LLVMContext* C);
protected:
/// The different symbols in the BrainF language
@@ -64,7 +65,7 @@ class BrainF {
static const char *testreg;
/// Put the brainf function preamble and other fixed pieces of code
- void header();
+ void header(LLVMContext* C);
/// The main loop for parsing. It calls itself recursively
/// to handle the depth of nesting of "[]".
diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp
index 06e77d2e2a..0868d73506 100644
--- a/examples/BrainF/BrainFDriver.cpp
+++ b/examples/BrainF/BrainFDriver.cpp
@@ -86,6 +86,8 @@ void addMainFunction(Module *mod) {
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " BrainF compiler\n");
+ LLVMContext Context;
+
if (InputFilename == "") {
std::cerr<<"Error: You must specify the filename of the program to "
"be compiled. Use --help to see the options.\n";
@@ -124,7 +126,7 @@ int main(int argc, char **argv) {
//Read the BrainF program
BrainF bf;
- Module *mod = bf.parse(in, 65536, cf); //64 KiB
+ Module *mod = bf.parse(in, 65536, cf, &Context); //64 KiB
if (in != &std::cin) {delete in;}
addMainFunction(mod);
diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp
index 09f2203c68..58c0dcdaf5 100644
--- a/examples/Fibonacci/fibonacci.cpp
+++ b/examples/Fibonacci/fibonacci.cpp
@@ -23,6 +23,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Constants.h"
@@ -90,8 +91,10 @@ static Function *CreateFibFunction(Module *M) {
int main(int argc, char **argv) {
int n = argc > 1 ? atol(argv[1]) : 24;
+ LLVMContext Context;
+
// Create some module to put our function into it.
- Module *M = new Module("test");
+ Module *M = new Module("test", &Context);
// We are about to create the "fib" function:
Function *FibF = CreateFibFunction(M);
diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp
index a9f10009e1..f11c3e256e 100644
--- a/examples/HowToUseJIT/HowToUseJIT.cpp
+++ b/examples/HowToUseJIT/HowToUseJIT.cpp
@@ -34,6 +34,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
@@ -50,9 +51,11 @@ using namespace llvm;
int main() {
InitializeNativeTarget();
+
+ LLVMContext Context;
// Create some module to put our function into it.
- Module *M = new Module("test");
+ Module *M = new Module("test", &Context);
// Create the add1 function entry and insert this entry into module M. The
// function will have a return type of "int" and take an argument of "int".
diff --git a/examples/Kaleidoscope/toy.cpp b/examples/Kaleidoscope/toy.cpp
index c75014a69b..9ca6035156 100644
--- a/examples/Kaleidoscope/toy.cpp
+++ b/examples/Kaleidoscope/toy.cpp
@@ -1,5 +1,6 @@
#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"
@@ -1083,6 +1084,7 @@ double printd(double X) {
int main() {
InitializeNativeTarget();
+ LLVMContext Context;
// Install standard binary operators.
// 1 is lowest precedence.
@@ -1097,7 +1099,7 @@ int main() {
getNextToken();
// Make the module, which holds all the code.
- TheModule = new Module("my cool jit");
+ TheModule = new Module("my cool jit", &Context);
// Create the JIT.
TheExecutionEngine = ExecutionEngine::create(TheModule);
diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp
index e2584e7ff3..322835e04f 100644
--- a/examples/ModuleMaker/ModuleMaker.cpp
+++ b/examples/ModuleMaker/ModuleMaker.cpp
@@ -13,6 +13,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Constants.h"
@@ -22,9 +23,11 @@
using namespace llvm;
int main() {
+ LLVMContext Context;
+
// Create the "module" or "program" or "translation unit" to hold the
// function
- Module *M = new Module("test");
+ Module *M = new Module("test", &Context);
// Create the main function: first create the type 'int ()'
FunctionType *FT = FunctionType::get(Type::Int32Ty, /*not vararg*/false);
diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp
index a6d7dcf7b5..858cd52de6 100644
--- a/examples/ParallelJIT/ParallelJIT.cpp
+++ b/examples/ParallelJIT/ParallelJIT.cpp
@@ -18,6 +18,7 @@
// same time). This test had assertion errors until I got the locking right.
#include <pthread.h>
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
@@ -232,9 +233,10 @@ void* callFunc( void* param )
int main() {
InitializeNativeTarget();
+ LLVMContext Context;
// Create some module to put our function into it.
- Module *M = new Module("test");
+ Module *M = new Module("test", &Context);
Function* add1F = createAdd1( M );
Function* fibF = CreateFibFunction( M );