如何在LLVM中创建ConstantInt? [英] How to create a ConstantInt in LLVM?

查看:274
本文介绍了如何在LLVM中创建ConstantInt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定如何在LLVM中创建ConstantInt,我知道我想创建的数字,但是我不确定如何制作一个代表该数字的ConstantInt.我似乎在文档中找不到所需的构造函数.

I'm not sure how to create a ConstantInt in LLVM- I know the number I would like to create, but I'm unsure how I can make a ConstantInt representing that number; I can't seem to find the constructor I need in the documentation.

我认为它必须与

ConstantInt consVal = new ConstantInt(something here).

我知道我希望它是一个int类型,而且我知道我的值...我只想创建一个数字!

I know I want it to be an int type, and I know my value... I just want to create a number!

推荐答案

LLVM中的大多数内容都是通过静态方法调用而不是直接使用构造函数创建的.原因之一是可以返回现有对象,而不用创建新实例.

Most things in LLVM are created through a static method call instead of directly using a constructor. One reason is that an existing object can be returned instead of creating a new instance.

ConstantInt的静态成员有许多创建方法.您可能对get (Type *Ty, uint64_t V, bool isSigned=false)最感兴趣,如果还没有整数类型,则可能是IntegerType::get (LLVMContext &C, unsigned NumBits).

The static members of ConstantInt have a number of creation methods. You're probably most interested in get (Type *Ty, uint64_t V, bool isSigned=false) and, if you don't already have an integer type, IntegerType::get (LLVMContext &C, unsigned NumBits).

这篇关于如何在LLVM中创建ConstantInt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆