簡體   English   中英

生成LLVM C ++ API代碼作為后端

[英]Generate LLVM C++ API code as backend

在線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。 在其他情況下,默認為全部。 示例:-DLLVM_TARGETS_TO_BUILD =“X86; PowerPC”。

UPDATE

version 3.9 ,CppBackend不再是一個有效的目標。 他們已從代碼中刪除,因為生成的代碼提出了一些問題。

檢查此提交

 Remove bit-rotten CppBackend. This backend was supposed to generate C++ code which will re-construct the LLVM IR passed as input. This seems to me to have very marginal usefulness in the first place. However, the code has never been updated to use IRBuilder, which makes its current value negative -- people who look at the output may be steered to use the *wrong* C++ APIs to construct IR. Furthermore, it's generated code that doesn't compile since at least 2013. Differential Revision: http://reviews.llvm.org/D19942 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268631 91177308-0d34-0410-b5e6-96231b3b80d8 

遺憾的是,在更新版本的LLVM中似乎不再可能。 相關的提交消息很好地解釋了它。

正如您在下面的提交中看到的, 刪除bit-rotten CppBackend ,生成的代碼將顯示問題。

commit 257fabb18605265a79397d35dd79a3973760ffaf
Author: ---
Date:   Thu May 5 14:35:40 2016 +0000

Remove bit-rotten CppBackend.

This backend was supposed to generate C++ code which will re-construct
the LLVM IR passed as input. This seems to me to have very marginal
usefulness in the first place.

However, the code has never been updated to use IRBuilder, which makes
its current value negative -- people who look at the output may be
steered to use the *wrong* C++ APIs to construct IR.

Furthermore, it's generated code that doesn't compile since at least
2013.

Differential Revision: http://reviews.llvm.org/D19942

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268631 91177308-0d34-0410-b5e6-96231b3b80d8

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM