Question about inserting IR code


From the file HowToUseJIT.cpp, I learned how to insert some calcuation IR code like Add/Sub/Mul etc by using

Instruction *Add = BinaryOperator::createAdd(One, ArgX, “addresult”, BB);

By following this way, it works well when I insert some IR code whose operand is integer type like IntTy, however, when I tried to insert similar thing whose operands are float point, I got the following message when I run it

void llvm::BinaryOperator::init(llvm::Instruction::BinaryOps,
llvm::Value*, llvm::Value*): Assertion `getType()->isIntegral() && “Tried
to create an logical operation on a non-integral type!”’ failed.

It seems that I cannot insert float point type operand by this way, right? If so, is there any way I can insert IR code whose operand are float point. I am trying to find some else class (not binaryOperator) to solve this problem, but I didn’t make it. Thanks.

BTW, allocaInst/storeInst/loadInst those works well for float point.


Are you sure you're calling createAdd and not createAnd? That error only
comes out when a logical operation (and, or, xor) is given floating
point operands.

Qiuyu Zhang wrote: