Search code examples
llvmllvm-clangllvm-gcc

Create functions in llvm pass with arguments and return type of type uint32_t and long double


Is there any way to create a function with return type and arguments as uint32_t and long double? For example, we can create argument of type int as follows:

 std::vector<Type*>FuncTy_args;
 FuncTy_args.push_back(IntegerType::get(M.getContext(), 32));

In the llvm link, http://llvm.org/docs/doxygen/html/classllvm_1_1Type.html. I can see only

static PointerType * getInt32PtrTy (LLVMContext &C, unsigned AS=0)

static PointerType *    getDoublePtrTy (LLVMContext &C, unsigned AS=0)

Solution

  • In LLVM IR, all types are represented in terms of type and number of bits. Once they are compiled, they lose the information of signed and unsigned. So once a C code is compiled to LLVM IR, types like uint32_t would become i32 and long double would become x86_fp80 since it's 80 bit floating format. Here is some information about types. I think you can use this function for long double. As for uint32_t, you can use this function.