简体   繁体   English

自动提升LLVM指令的输入值

[英]Automatically promoting input values for LLVM instructions

When using the IR Builder obviously I can build IR that is invalid, eg by adding two values with incompatible type, like i32 and float . 显然,当使用IR Builder时,我可以构建无效的IR,例如,通过添加两个不兼容类型的值,例如i32float Is there a facility that kind of promotes values (or better users) automatically according to the semantics of the instruction? 是否存在一种根据指令的语义自动提升价值(或更好的用户)的工具? Something like: 就像是:

Value * CreateSafeFAdd (Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=0)

which would promote input values, eg in case they are integers. 这将提升输入值,例如在它们是整数的情况下。 And it would promote to the higher floating-point precision, in case one of the input arguments' type is float and the other is double . 如果输入参数的类型之一是float ,而另一个参数是double ,它将提高到更高的浮点精度。

If not, I assume I will have to take of all type conversions in order to build valid IR. 如果没有,我假设我将必须进行所有类型转换才能构建有效的IR。

类型对话必须由构建IR的人处理,但是您可以使用Value::getType()来创建自己的CreateSafeFAdd函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM