<div dir="ltr"><br><div>Hi Roel,</div><div><br></div><div>I understand that C and C++ backends are special cases. My concern is, since two different functionalities are offered by two deceptively identical arguments (i.e. march=c and march=cpp), it's easy for a beginner like me to stumble upon at this inconsistency. I myself had a hard time grasping the fact, especially when the <a href="http://llvm.org/docs/CommandGuide/llc.html">official documentation</a> is inadequate.</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The llc command compiles LLVM source inputs into assembly language for a specified architecture. The assembly language output can then be passed through a native assembler and linker to generate a native executable.<br>The choice of architecture for the output assembly code is automatically determined from the input file, unless the -march option is used to override the default.</blockquote><div><br></div><div> At this point, I know that the support for C backend has been dropped in <a href="http://llvm.org/releases/3.1/docs/ReleaseNotes.html">LLVM release 3.1</a> and above.</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The C backend has been removed. It had numerous problems, to the point of not being able to compile any nontrivial program.</blockquote><div><br></div><div>At the same time, I'd be interested to know the use-cases of C++ backend and how to compile the C++ code (to generate IR) that LLVM C++ backend generates.</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 9 September 2015 at 18:00, Roel Jordans via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dipanjan,<br>
<br>
The llc utility is complete interface to the LLVM back-ends, it helps you translate LLVM IR into a target's native code.  As such there are more "target architectures" that you can select when using llc, you can get a list of them with "llc --version" (at least, that's how it works with the current versions of LLVM, 2.9 is rather ancient).<br>
<br>
The C and C++ back-ends are rather special cases.  The C back-end (which no-longer exists in the current LLVM version as it wasn't maintained anymore) aims at translating the IR back to compilable C code, as you already observed.  The intent of this back-end was that it allows a user to utilize the optimizations and front-end of LLVM even if LLVM doesn't support the user's target architecture by generating an "optimized" C code which can then be used with another compiler.<br>
<br>
The C++ back-end has a different purpose, it serves to show how IR code can be generated from LLVM's C++ library interface.  This is more useful if you are writing a program that should generate IR code input for LLVM and want to see how a particular IR construct can be created.  There are probably other uses for the C++ back-end but that's the main one I've seen so far.<br>
<br>
So, in general, if you want to generate code that is compilable into a native binary, use the C back-end (although it may be broken in many ways due to lack of maintenance), or try to see if there is a real back-end for your target architecture so that you can generate code more directly.<br>
<br>
Cheers,<br>
 Roel<br>
<br>
On 09/09/15 11:43, Dipanjan Das via llvm-dev wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Hi,<br>
<br>
I am working with LLVM 2.9. So far I have used "llc -march=c" and "llc<br>
-march=cpp" respectively to generate C and C++ source code from LLVM<br>
IR/BitCode. My questions follow:<br>
<br>
 1. I can see that there is a significant difference between the code<br>
    generated by C and C++ backends. Former one generates code to be<br>
    compiled by gcc to generate a native executable, while the later one<br>
    is targeted to generated LLVM IR itself. Surprisingly, both the<br>
    diametrically opposite functionalities have been put together in the<br>
    same utility called ''llc'. I wonder if there is any official doc<br>
    available online to point out the striking difference.<br>
 2. This question is simpler even: How can I make use of the C++ code<br>
    generated by LLVM C++ backend? In other words, can it be compiled to<br>
    a standalone, native binary that can be used to write out<br>
    corresponding LLVM IR? If so, what will the compiler and linker<br>
    switches be?<br>
<br>
Thanks in advance.<br>
<br>
--<br>
<br>
Thanks & Regards,<br>
<br>
Dipanjan<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><span><div><div dir="ltr"><p>Thanks & Regards,</p>
<div>Dipanjan</div></div></div></span></div></div>
</div></div>