mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-05-13 18:45:55 +00:00
add some casts to support a change in the getOrInsertFunction interface
llvm-svn: 32984
This commit is contained in:
parent
a62936ee6f
commit
1990df521b
@ -38,8 +38,9 @@ using namespace llvm;
|
|||||||
static Function *CreateFibFunction(Module *M) {
|
static Function *CreateFibFunction(Module *M) {
|
||||||
// Create the fib function and insert it into module M. This function is said
|
// Create the fib function and insert it into module M. This function is said
|
||||||
// to return an int and take an int parameter.
|
// to return an int and take an int parameter.
|
||||||
Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
|
Function *FibF =
|
||||||
(Type *)0);
|
cast<Function>(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
|
||||||
|
(Type *)0));
|
||||||
|
|
||||||
// Add a basic block to the function.
|
// Add a basic block to the function.
|
||||||
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
|
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
|
||||||
|
@ -52,8 +52,9 @@ int main() {
|
|||||||
// Create the add1 function entry and insert this entry into module M. The
|
// 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".
|
// function will have a return type of "int" and take an argument of "int".
|
||||||
// The '0' terminates the list of argument types.
|
// The '0' terminates the list of argument types.
|
||||||
Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
|
Function *Add1F =
|
||||||
(Type *)0);
|
cast<Function>(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
|
||||||
|
(Type *)0));
|
||||||
|
|
||||||
// Add a basic block to the function. As before, it automatically inserts
|
// Add a basic block to the function. As before, it automatically inserts
|
||||||
// because of the last argument.
|
// because of the last argument.
|
||||||
@ -78,7 +79,8 @@ int main() {
|
|||||||
|
|
||||||
// Now we going to create function `foo', which returns an int and takes no
|
// Now we going to create function `foo', which returns an int and takes no
|
||||||
// arguments.
|
// arguments.
|
||||||
Function *FooF = M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0);
|
Function *FooF =
|
||||||
|
cast<Function>(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0));
|
||||||
|
|
||||||
// Add a basic block to the FooF function.
|
// Add a basic block to the FooF function.
|
||||||
BB = new BasicBlock("EntryBlock", FooF);
|
BB = new BasicBlock("EntryBlock", FooF);
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static Function* createAdd1(Module* M)
|
static Function* createAdd1(Module *M) {
|
||||||
{
|
|
||||||
// Create the add1 function entry and insert this entry into module M. The
|
// 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".
|
// function will have a return type of "int" and take an argument of "int".
|
||||||
// The '0' terminates the list of argument types.
|
// The '0' terminates the list of argument types.
|
||||||
Function *Add1F = M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
|
Function *Add1F =
|
||||||
(Type *)0);
|
cast<Function>(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
|
||||||
|
(Type *)0));
|
||||||
|
|
||||||
// Add a basic block to the function. As before, it automatically inserts
|
// Add a basic block to the function. As before, it automatically inserts
|
||||||
// because of the last argument.
|
// because of the last argument.
|
||||||
@ -59,12 +59,12 @@ static Function* createAdd1(Module* M)
|
|||||||
return Add1F;
|
return Add1F;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Function *CreateFibFunction(Module *M)
|
static Function *CreateFibFunction(Module *M) {
|
||||||
{
|
|
||||||
// Create the fib function and insert it into module M. This function is said
|
// Create the fib function and insert it into module M. This function is said
|
||||||
// to return an int and take an int parameter.
|
// to return an int and take an int parameter.
|
||||||
Function *FibF = M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
|
Function *FibF =
|
||||||
(Type *)0);
|
cast<Function>(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
|
||||||
|
(Type *)0));
|
||||||
|
|
||||||
// Add a basic block to the function.
|
// Add a basic block to the function.
|
||||||
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
|
BasicBlock *BB = new BasicBlock("EntryBlock", FibF);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user