将std :: string转换为llvm :: MemoryBuffer [英] Convert std::string to llvm::MemoryBuffer

查看:171
本文介绍了将std :: string转换为llvm :: MemoryBuffer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从现有的LLVM IR代码创建LLVM模块.

I am looking to create an LLVM Module from existing LLVM IR code.

我发现的两种方法如下:

The two methods I have found are the following:

  • ParseIRFile-这将接受文件名并生成一个模块
  • ParseIR-这接受MemoryBuffer并生成一个模块
  • ParseIRFile - This accepts a file name and generates a module
  • ParseIR - This accepts MemoryBuffer and generates a module

当LLVM IR已作为std::stringconst char *读取到字符串时,我想创建一个模块.

I want to create a Module when the LLVM IR is already read to a string as an std::string or const char *.

是否可以将IR字符串转换为llvm::MemoryBuffer?

Is there a way to convert an IR string to llvm::MemoryBuffer ?

推荐答案

我在同事的帮助下解决了这个问题.

I figured this out with the help of a colleague.

这是您要执行的操作:

std::string IRString = readfile("add.ll");
MemoryBuffer *mem = MemoryBuffer::getMemBuffer(IRString);

这篇关于将std :: string转换为llvm :: MemoryBuffer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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