December 2015
Beginner to intermediate
166 pages
3h 8m
English
A function takes arguments that have their own data type. For simplification, assume that our function has all the arguments of i32 type (integer 32 bit).
For example, we will consider that two arguments, a and b, are passed to the function. We will store these two arguments in a vector:
static std::vector <std::string> FunArgs;
FunArgs.push_back("a");
FunArgs.push_back("b");
The next step is to specify that the function will have two arguments. This can be done by passing the Integer argument to the functiontype.
Function *createFunc(IRBuilder<> &Builder, std::string Name) {
std::vector<Type *> Integers(FunArgs.size(), Type::getInt32Ty(Context)); FunctionType *funcType = llvm::FunctionType::get(Builder.getInt32Ty(), ...Read now
Unlock full access