llvm.org GIT mirror llvm / 6a98754
add some casts to support a change in the getOrInsertFunction interface git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32984 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
3 changed file(s) with 16 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
3737 static Function *CreateFibFunction(Module *M) {
3838 // Create the fib function and insert it into module M. This function is said
3939 // to return an int and take an int parameter.
40 Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
41 (Type *)0);
40 Function *FibF =
41 cast(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
42 (Type *)0));
4243
4344 // Add a basic block to the function.
4445 BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
5151 // Create the add1 function entry and insert this entry into module M. The
5252 // function will have a return type of "int" and take an argument of "int".
5353 // The '0' terminates the list of argument types.
54 Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
55 (Type *)0);
54 Function *Add1F =
55 cast(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
56 (Type *)0));
5657
5758 // Add a basic block to the function. As before, it automatically inserts
5859 // because of the last argument.
7778
7879 // Now we going to create function `foo', which returns an int and takes no
7980 // arguments.
80 Function *FooF = M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0);
81 Function *FooF =
82 cast(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0));
8183
8284 // Add a basic block to the FooF function.
8385 BB = new BasicBlock("EntryBlock", FooF);
2828 #include
2929 using namespace llvm;
3030
31 static Function* createAdd1(Module* M)
32 {
31 static Function* createAdd1(Module *M) {
3332 // Create the add1 function entry and insert this entry into module M. The
3433 // function will have a return type of "int" and take an argument of "int".
3534 // The '0' terminates the list of argument types.
36 Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
37 (Type *)0);
35 Function *Add1F =
36 cast(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
37 (Type *)0));
3838
3939 // Add a basic block to the function. As before, it automatically inserts
4040 // because of the last argument.
5858 return Add1F;
5959 }
6060
61 static Function *CreateFibFunction(Module *M)
62 {
61 static Function *CreateFibFunction(Module *M) {
6362 // Create the fib function and insert it into module M. This function is said
6463 // to return an int and take an int parameter.
65 Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
66 (Type *)0);
64 Function *FibF =
65 cast(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
66 (Type *)0));
6767
6868 // Add a basic block to the function.
6969 BasicBlock *BB = new BasicBlock("EntryBlock", FibF);