Emitting function arguments

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(), ...

Get LLVM Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.