Is it possible to automatically generate llvm C ++ api code from LLVM-IR?

The clang 3.0 demo page http://llvm.org/demo/index.cgi provides the ability to output LLVM C ++ API code representing LLVM-IR for an input program.

Is the "LLVM C ++ API code" return a clang parameter (and if so, what is it)?

Or is it the llvm tool parameter (which one)?

Is it possible to do the same, but from the LLVM-IR input? Basically, I would like to see the correct llvm C ++ api calls needed to create a particular given llvm-ir sequence. I would like to learn back from an example, not forward from the documentation.

The man pages and --help and --help-hidden for clang, llvm-as and llvm-dis show nothing obvious.

edit: OK, now I see the output on this web page, "generated llvm2cpp". But I can not find this tool in the latest releases of llvm, only in older versions, has a new tool appeared in versions 2.9 and 3.0 for llvm2cpp?

+6
source share
2 answers

Yes. C ++ is a tool that does this. Try "llc -march = cpp foo.bc"

+8
source

I ran into the same problem and saw what CPPBuilder mentioned a couple of times. This approach, unfortunately, no longer works in recent versions of LLVM, since CPPBackend has been removed between 3.8 and 3.9.

If you want the CPP backend (i) to configure llvm and add cppbackend to -DLLVM_TARGETS_TO_BUILD during initial setup and (ii) run llvm <= 3.8.

The function was removed because it did not use IRBuilder, and almost no one used it. My solution was to rely on the old version to get inspiration, and then implement it yourself.

+1
source

Source: https://habr.com/ru/post/911480/


All Articles