生成LLVM C ++ API代码作为后端 [英] Generate LLVM C++ API code as backend

查看:864
本文介绍了生成LLVM C ++ API代码作为后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线LLVM演示页面具有从源代码生成LLVM C ++ API代码作为后端的选项。但是,该演示页现在已禁用。我想知道我们如何使用可用的LLVM工具自己做。



我试过下面的

  clang ++ -c -emit-llvm input.cpp -o input.ll 
llc -march = cpp -o input.ll.cpp input.ll



这会产生以下错误:

  llc:error:invalid target'cpp'。 

我使用LLVM / Clang版本3.2。

解决方案

在构建LLVM时,必须在配置期间启用LLVM C ++后端。它在默认情况下在 configure (autotools)构建中启用,但在Windows上构建时不在CMake构建中。您可以通过在使用CMake配置时设置相应的标志来启用它。有关详情,请参见此页



报价:



LLVM_TARGETS_TO_BUILD:STRING
要构建的目标的分号列表,建立所有目标。区分大小写。对于Visual C ++默认为X86。在
上其他情况默认为​​all。示例:
-DLLVM_TARGETS_TO_BUILD =X86; PowerPC。



The Online LLVM demo page had an option to generate LLVM C++ API code as backend from a source code. However, that demo page is now disabled. I was wondering how we can do it ourselves using the available LLVM tools.

I tried the following

clang++ -c -emit-llvm input.cpp -o input.ll
llc -march=cpp -o input.ll.cpp input.ll

which gives the following error

llc: error: invalid target 'cpp'.

I am using LLVM/Clang version 3.2.

解决方案

The LLVM C++ backend has to be enabled during configuration when building LLVM. It's enabled by default in the configure (autotools) build, but not in the CMake build when you build on Windows. You can enable it by setting the appropriate flags while configuring with CMake. See this page for more information.

Quote:

LLVM_TARGETS_TO_BUILD:STRING Semicolon-separated list of targets to build, or all for building all targets. Case-sensitive. For Visual C++ defaults to X86. On the other cases defaults to all. Example: -DLLVM_TARGETS_TO_BUILD="X86;PowerPC".

这篇关于生成LLVM C ++ API代码作为后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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