Convert constant Double to Int in llvm IR

有些话、适合烂在心里 提交于 2019-12-11 23:24:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!