问题
Given the following IR,
%1 = call double @llvm.pow.f64(double %conv, double 9.000000e+00)
when the fraction part of second argument is zero, I want to get it(second argument) in int type.
Can someone please suggest a method for this conversion?
Thank you in advance.
回答1:
There are conversion instructions for this:
fptoui
fptosi
EDIT:
If you wish to convert llvm::ConstantFP, you can call getValueAPF() method, which would return you llvm::APFloat. See documentation on how to convert llvm::APFloat to integer.
来源:https://stackoverflow.com/questions/9288549/convert-constant-double-to-int-in-llvm-ir