What is the alternative to "'llc -march=cpp" in LLVM 12 - llvm

LLVM used to provide llc -march=cpp test.ll -o test.cpp instruction to learn C++ API, but this is not available in llvm 12.

Unfortunately, there is no alternative. The reason why C++ backend was removed long time ago is quite simple: it did not serve its main intention to be a guide to LLVM C++ API well, it generated suboptimal code and was not updated to support the latest changes to C++ API.
You can use the code of existing transformation passes to learn LLVM C++ API

Related

Popular LLVM version

First I'm sorry for my poor English and ambiguous questions.
I'm now trying to create an llvm front-end for new language that defined by me.
More detail, I'm making scanners, parsers, and IR code generators.
I'm now making IR Code generator using LLVM API(C++) such as IRBuilder, Context, Module.. etc
But i recently know that the LLVM API does not support backward compatibility.
Depending on the version, header file paths are different, or some functions and classes are not supported.
So, my question is below:
Which LLVM version is the most popular?
What LLVM version should I use for my project?
I want to make my project as portable.
In the other words, I want to make my project that minimize problems occurs when build my project in other environments.
Now I'm using LLVM 6.0.0svn version. That is result of following this page:
(https://llvm.org/docs/GettingStarted.html)
But i know how to install llvm previous version.
Thank you for reading.
IR building API is more or less stable. As for "popularity", there is no such thing as most popular version. It is up to you, language writers, to choose what version of LLVM to use. Some languages try to closely follow tip-of-head, so they are compatible with fresh releases. Others make switch from time to time, on the need basis. Finally, there are tools like KLEE that try to keep compatibility across different version using #ifdefs, and this turned out to be not very hard.
I would recommend using the latest version as it can be difficult to find documentation for older versions and of course the newer versions provide more features.

Integration of Rcpp in c++ with bcc compiler

Hi I`m looking for a library in c++ which i compile with the borland compiler bcc32.
Before I tried to take the benefits of RInside but unfortunately it´s only working with gcc-compiler and can´t be used in my programming environment, wich is Embarcadero.
Is it possible to use Rcpp with a bcc32 compiler?
Are there compatitible librarys on the market doing statistical calculations in c++
I hope you can help me. Thanks.
Part 1: no. From the Rcpp FAQ:
1.3. What compiler can I use. On almost all platforms, the GNU
Compiler Collection (or gcc, which is also the name of its
C language compiler) has to be used along with the corresponding
g++ compiler for the
C++ language. ...
The
clang
and
clang++
compilers from the LLVM project can
also be used ...
The Intel
icc
family has also been used successfully as its output
files can also be combined with those from
gcc
.
If it's not on that list, it's not supported.
Part 2: off topic for StackOverflow.

Possible to auto-generate llvm c++ api code from LLVM-IR?

The clang 3.0 online demo page http://llvm.org/demo/index.cgi provides an option to output LLVM C++ API code" representing the LLVM-IR for the input program.
Is "produce LLVM C++ API code" output a clang option (and if so, what is it)?
Or is it an llvm tool option (which one)?
Is it possible to do the same thing but from LLVM-IR input? Basically I'd like to see the proper llvm c++ api calls needed to produce a particular given llvm-ir sequence. I'd like to learn backwards by example rather than forwards from the documentation.
Manual pages and --help and --help-hidden for clang, llvm-as and llvm-dis don't show anything obvious.
edit: OK now I see in the output on that web page, "generated by llvm2cpp". But I can't find that tool in recent llvm releases, only old releases, has a new tool in 2.9 and 3.0 taken over for llvm2cpp?
Yes. C++ backend is the tool which does this. Try "llc -march=cpp foo.bc"
I ran into exactly the same problem and saw the CPPBuilder mentioned a couple of times. This approach unfortunately no longer works on recent LLVM versions as the CPPBackend was removed between 3.8 and 3.9.
If you want the CPP backend you (i) have to configure llvm and add cppbackend to -DLLVM_TARGETS_TO_BUILD during the initial configure and (ii) run an llvm <= 3.8.
The feature was removed because it did not use IRBuilder and almost nobody used it. My solution was to rely on the old version to get inspired, then implement it myself.

LLVM compiler for production code?

I have a question concerning the LLVM compiler:
I would like to use it to compile my Objective-C source code for Mac and iOS and from their release notes it seems that LLVM is stable enough for using this.
Having made good experiences with the LLVM I would also like to use it to compile C++ or Objective-C++. However it is not clear to me if I should still use the hybrid LLVM-GCC compiler (the GCC parser and the LLVM code generator) or the pure LLVM compiler.
I am also unsure about the new C++ standard library and if I should use it and how I would make the transition from GNU's libstdc++.
The Questions
Which compiler would one use today to generate fast production quality code from C++: the LLVM-GCC hybrid compiler or pure LLVM?
Should one migrate the C++ standard library from GNU's libstdc++ to the new libc++ library created by the LLVM project?
Any comments and hints are appreciated.
Several questions asked here, I'll try to answer all of them.
There is no "pure LLVM compiler". LLVM is a set of libraries which do code optimization and code generation . There are several C/C++ frontends which can be hooked to LLVM. Among them are clang and llvm-gcc. See http://llvm.org/ for more information about various components of LLVM Compiler Infrastructure. As written at http://llvm.org/docs/ReleaseNotes.html, llvm-gcc is EOL since LLVM 2.9 release, so you'd better use clang, because it will certainly be developed and maintained in the future.
libc++ is still in development, so for production you should use vendor-provided C++ (libstdc++ in your case).
Remember, all this stuff is changing, so benchmarks gets easily outdated.
I've found following report interesting, not only as a kind of benchmark, but it seems showing some LLVM vs GCC compiler differences :
Clang/LLVM Maturity Evaluation Report by Dominic Fandrey

C++ frontend only compiler (convert C++ to C)

I'm currently managing some C++ code that runs on multiple platforms from a single source tree (Win32, Linux, Verifone CC terminals, MBED and even the Nintendo GBA/DS). However I need to build an app targetted at an embedded platform for which there is no C++ compiler (C only). I remmber that many of the early C++ compilers were only front-ends stitting on existing C compilers (Glockenspiel for example used MSC). Are there any such 'frontend' C++ compilers in use today that will generate C code.
Tools Platform
----------- ------------
______Visual C++ _____ WIN32
/
/_______MBED (ARM)_______MBED (ARM dev board).
/
/_________GCC (x86)________Linux
/
Source____/___________GCC (ARM)________GBA/DS
\
\__________SDA______________Verifone Verix CC Terminals
\
\________ARM SDT__________Verifine VerixV CC terminals
\
\______????_____________Renases M8/16/32.
\
\____????_____________Z8 family.
The last two platforms I have good C compilers for but no C++.
As you can see I'm supporting a large variety of platforms and I share a large body of library code (and some app code).
If you use LLVM, llvm-g++ will compile your C++ code to LLVM bitcode, and llc has a backend which converts bitcode to C.
You could write commands like this:
llvm-g++ -emit-llvm -c foo.cpp -o foo.o
llc -march=c <foo.o >foo.c
Comeau C++ does this.
Can't help with the Z8, but the Renesas M16C/M32C family has GCC these days - see http://www.kpitgnutools.com/ for prebuilt cross toolchain hosted on Windows. Haven't used it myself yet but may be a better option than a 3rd party C++ frontend, especially as your code already targets GCC on other platforms.
Comeau C++ generates C as its output, and they seem to be quite happy to port it to work with different back-end compilers, though I'm not sure about the exact pricing for that.
If you want a bit more of a "roll your own" approach, you could buy a license to the EDG C++ compiler. It's normally used as a front-end (e.g. by Comeau and Intel) but I believe as it's shipped, it includes a code generator that produces C as its output. Its licensing is oriented more toward compiler vendors, though, so a license gives you a lot of rights, but is pretty expensive.
Out of date, but maybe you want to try cfront?
I'll leave this for information - cfront doesn't have exception support.
Of what I have understood, the c++ support in gcc for r8c/m16c/r32c isn't quite mature and good enough for production code. But for r8c/m16c/m32c/r32c there is at least one compiler supporting embedded C++ and that is IAR, I think Tasking also supports embedded C++ on m16c.
Notice that the valid solution is for llvm 1.3
llvm last release was 6.0.0 so it would'nt work at all.
(I post this because i've try the solution of this post but it doesn't work anymore) (Maybe i've done something bad)
In my tests llc do not accept anymore the -march=c option.
And going back to the 1.3 isn't possible for me yet.
So try to take care about the version.