我有我想要添加的值ConstantInt
和值。但是,我无法将其转换为可以接受的浮点数。ConstantFP
fadd
ConstantInt
fadd
这是代码的摘录:
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());
哪里currentBlock()
返回一个BasicBlock
。在尝试为此生成操作码后,LLVM 抱怨它无法添加这两个值,因为它们不一样。
我对 LLVM 比较陌生,所以如果这段代码没有意义,我会接受任何建议。