summaryrefslogtreecommitdiffstats
path: root/llvm/examples/BrainF
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/examples/BrainF')
-rw-r--r--llvm/examples/BrainF/BrainF.cpp18
-rw-r--r--llvm/examples/BrainF/BrainF.h6
-rw-r--r--llvm/examples/BrainF/BrainFDriver.cpp12
3 files changed, 18 insertions, 18 deletions
diff --git a/llvm/examples/BrainF/BrainF.cpp b/llvm/examples/BrainF/BrainF.cpp
index b4cbc780a04..bcd75325e80 100644
--- a/llvm/examples/BrainF/BrainF.cpp
+++ b/llvm/examples/BrainF/BrainF.cpp
@@ -72,17 +72,19 @@ void BrainF::header(LLVMContext& C) {
Tys);
//declare i32 @getchar()
- getchar_func =
- module->getOrInsertFunction("getchar", IntegerType::getInt32Ty(C));
+ getchar_func = cast<Function>(module->
+ getOrInsertFunction("getchar", IntegerType::getInt32Ty(C)));
//declare i32 @putchar(i32)
- putchar_func = module->getOrInsertFunction(
- "putchar", IntegerType::getInt32Ty(C), IntegerType::getInt32Ty(C));
+ putchar_func = cast<Function>(module->
+ getOrInsertFunction("putchar", IntegerType::getInt32Ty(C),
+ IntegerType::getInt32Ty(C)));
//Function header
//define void @brainf()
- brainf_func = module->getOrInsertFunction("brainf", Type::getVoidTy(C));
+ brainf_func = cast<Function>(module->
+ getOrInsertFunction("brainf", Type::getVoidTy(C)));
builder = new IRBuilder<>(BasicBlock::Create(C, label, brainf_func));
@@ -151,9 +153,9 @@ void BrainF::header(LLVMContext& C) {
"aberrormsg");
//declare i32 @puts(i8 *)
- FunctionCallee puts_func = module->getOrInsertFunction(
- "puts", IntegerType::getInt32Ty(C),
- PointerType::getUnqual(IntegerType::getInt8Ty(C)));
+ Function *puts_func = cast<Function>(module->
+ getOrInsertFunction("puts", IntegerType::getInt32Ty(C),
+ PointerType::getUnqual(IntegerType::getInt8Ty(C))));
//brainf.aberror:
aberrorbb = BasicBlock::Create(C, label, brainf_func);
diff --git a/llvm/examples/BrainF/BrainF.h b/llvm/examples/BrainF/BrainF.h
index 9d6848e5bc6..a2c04f8cb79 100644
--- a/llvm/examples/BrainF/BrainF.h
+++ b/llvm/examples/BrainF/BrainF.h
@@ -78,9 +78,9 @@ class BrainF {
CompileFlags comflag;
std::istream *in;
Module *module;
- FunctionCallee brainf_func;
- FunctionCallee getchar_func;
- FunctionCallee putchar_func;
+ Function *brainf_func;
+ Function *getchar_func;
+ Function *putchar_func;
Value *ptr_arr;
Value *ptr_arrmax;
BasicBlock *endbb;
diff --git a/llvm/examples/BrainF/BrainFDriver.cpp b/llvm/examples/BrainF/BrainFDriver.cpp
index 2c63b254246..85c563d136d 100644
--- a/llvm/examples/BrainF/BrainFDriver.cpp
+++ b/llvm/examples/BrainF/BrainFDriver.cpp
@@ -72,13 +72,11 @@ JIT("jit", cl::desc("Run program Just-In-Time"));
//Add main function so can be fully compiled
void addMainFunction(Module *mod) {
//define i32 @main(i32 %argc, i8 **%argv)
- FunctionType *main_func_fty = FunctionType::get(
- Type::getInt32Ty(mod->getContext()),
- {Type::getInt32Ty(mod->getContext()),
- Type::getInt8Ty(mod->getContext())->getPointerTo()->getPointerTo()});
- Function *main_func =
- Function::create(main_func_fty, Function::ExternalLinkage, "main", mod);
-
+ Function *main_func = cast<Function>(mod->
+ getOrInsertFunction("main", IntegerType::getInt32Ty(mod->getContext()),
+ IntegerType::getInt32Ty(mod->getContext()),
+ PointerType::getUnqual(PointerType::getUnqual(
+ IntegerType::getInt8Ty(mod->getContext())))));
{
Function::arg_iterator args = main_func->arg_begin();
Value *arg_0 = &*args++;
OpenPOWER on IntegriCloud