I have ConstantInt and ConstantFP values that I want to add using fadd. However, I'm having trouble casting the ConstantInt into a floating point number that fadd will accept.
Here is an excerpt of the code:
Value* left = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 12, true);
Value* right = ConstantFP::get(Type::getFloatTy(getGlobalContext()), 11.6);
Instruction* cast = CastInst::Create(Instruction::SIToFP, left, left->getType(), "", currentBlock());
left = cast->getOperand(0);
BinaryOperator::Create(Instruction::FAdd, left, right, "", currentBlock());
where currentBlock() returns a BasicBlock. After trying to generate the opcode for this, LLVM complains that it can't add the two values because they are not the same.
I'm rather new to LLVM, so I'll take any advice if this code makes no sense.