Convert constant Double to Int in llvm IR

2019-08-20 09:10发布

问题:

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.



标签: llvm