-// This file was developed by Valery A. Khamenya and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
#include "llvm/Instructions.h"
#include "llvm/ModuleProvider.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Instructions.h"
#include "llvm/ModuleProvider.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
// Get pointers to the constant `1'.
Value *One = ConstantInt::get(Type::Int32Ty, 1);
// Get pointers to the constant `1'.
Value *One = ConstantInt::get(Type::Int32Ty, 1);
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the add instruction, inserting it into the end of BB.
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the add instruction, inserting it into the end of BB.
- Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB);
+ Instruction *Add = BinaryOperator::CreateAdd(One, ArgX, "addresult", BB);
cast<Function>(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0));
// Add a basic block to the FooF function.
cast<Function>(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0));
// Add a basic block to the FooF function.
// Get pointers to the constant `10'.
Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
// Pass Ten to the call call:
// Get pointers to the constant `10'.
Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
// Pass Ten to the call call:
- std::vector<Value*> Params;
- Params.push_back(Ten);
- CallInst *Add1CallRes = new CallInst(Add1F, Params, "add1", BB);
+ CallInst *Add1CallRes = CallInst::Create(Add1F, Ten, "add1", BB);
// Now we create the JIT.
ExistingModuleProvider* MP = new ExistingModuleProvider(M);
ExecutionEngine* EE = ExecutionEngine::create(MP, false);
// Now we create the JIT.
ExistingModuleProvider* MP = new ExistingModuleProvider(M);
ExecutionEngine* EE = ExecutionEngine::create(MP, false);
- std::cout << "We just constructed this LLVM module:\n\n" << *M;
- std::cout << "\n\nRunning foo: " << std::flush;
+ outs() << "We just constructed this LLVM module:\n\n" << *M;
+ outs() << "\n\nRunning foo: ";
+ outs().flush();
// Call the `foo' function with no arguments:
std::vector<GenericValue> noargs;
GenericValue gv = EE->runFunction(FooF, noargs);
// Import result of execution:
// Call the `foo' function with no arguments:
std::vector<GenericValue> noargs;
GenericValue gv = EE->runFunction(FooF, noargs);
// Import result of execution: