[llvm-commits] [llvm] r64222 - /llvm/trunk/docs/FAQ.html

Dan Gohman gohman at apple.com
Tue Feb 10 09:26:53 PST 2009


Author: djg
Date: Tue Feb 10 11:26:53 2009
New Revision: 64222

URL: http://llvm.org/viewvc/llvm-project?rev=64222&view=rev
Log:
Answer a common FAQ:
"Can I compile C or C++ code to platform-independent LLVM bitcode?"

Modified:
    llvm/trunk/docs/FAQ.html

Modified: llvm/trunk/docs/FAQ.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/FAQ.html?rev=64222&r1=64221&r2=64222&view=diff

==============================================================================
--- llvm/trunk/docs/FAQ.html (original)
+++ llvm/trunk/docs/FAQ.html Tue Feb 10 11:26:53 2009
@@ -87,6 +87,8 @@
 
     <li><a href="#translatecxx">Can I use LLVM to convert C++ code to C code?</a></li>
 
+    <li><a href="#platformindependent">Can I compile C or C++ code to platform-independent LLVM bitcode?</a></li>
+
   </ol>
   </li>
 
@@ -629,6 +631,31 @@
 
 </div>
 
+<div class="question">
+<p>
+<a name="platformindependent">Can I compile C or C++ code to platform-independent LLVM bitcode?</a>
+</p>
+</div>
+
+<div class="answer">
+
+<p>No. C and C++ are inherently platform-dependent languages. The most
+obvious example of this is the preprocessor. A very common way that C code
+is made portable is by using the preprocessor to include platform-specific
+code. In practice, information about other platforms is lost after
+preprocessing, so the result is inherently dependent on the platform that
+the preprocessing was targetting.</p>
+
+<p>Another example is <tt>sizeof</tt>. It's common for <tt>sizeof(long)</tt>
+to vary between platforms. In most C front-ends, <tt>sizeof</tt> is expanded
+to a constant immediately, thus hardwaring a platform-specific detail.</p>
+
+<p>Also, since many platforms define their ABIs in terms of C, and since
+LLVM is lower-level than C, front-ends currently must emit platform-specific
+IR in order to have the result conform to the platform ABI.</p>
+
+</div>
+
 <!-- *********************************************************************** -->
 <div class="doc_section">
   <a name="cfe_code">Questions about code generated by the GCC front-end</a>





More information about the llvm-commits mailing list