bd06debbaa64f51dcbfbc7a98745c98c2ef7d8dc
[oota-llvm.git] / docs / LLVMVsTheWorld.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2                       "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5   <link rel="stylesheet" href="llvm.css" type="text/css">
6   <title>LLVM vs. the World - Comparing Compilers to Compilers</title>
7 </head>
8
9 <body>
10
11 <div class="doc_title">
12   LLVM vs. the World - Comparing Compilers to Compilers
13 </div>
14
15 <ol>
16   <li><a href="#introduction">Introduction</a></li>
17   <li><a href="#generalapplicability">General Applicability</a></li>
18   <li><a href="#typesystem">Type System</a></li>
19   <li><a href="#dataflowinformation">Control-flow and Data-flow Information</a></li>
20   <li><a href="#registers">Registers</a></li>
21   <li><a href="#programmerinterface">Programmer Interface</a></li>
22   <li><a href="#codeemission">Machine Code Emission</a></li>
23 </ol>
24
25 <div class="doc_text">    
26   <p><b>Written by Brian R. Gaeke</b></p>
27 </div>
28
29 <!-- *********************************************************************** -->
30 <div class="doc_section">
31   <a name="introduction">Introduction</a>
32 </div>
33 <!-- *********************************************************************** -->
34
35 <div class="doc_text">
36 <p>Whether you are a stranger to LLVM or not, and whether you are considering
37 using it for your projects or not, you may find it useful to understand how we
38 compare ourselves to other well-known compilers. The following list of points
39 should help you understand -- from our point of view -- some of the important
40 ways in which we see LLVM as different from other selected compilers and
41 code generation systems.</p>
42
43 <p>At the moment, we only compare ourselves below to <a
44 href="http://gcc.gnu.org/">GCC</a> and <a
45 href="http://www.gnu.org/software/lightning/">GNU lightning</a>, but we will try
46 to revise and expand it as our knowledge and experience permit. Contributions are
47 welcome.</p>
48 </div>
49
50 <!-- *********************************************************************** -->
51 <div class="doc_section">
52   <a name="generalapplicability">General Applicability</a>
53 </div>
54 <!-- *********************************************************************** -->
55
56 <div class="doc_text">
57 <p>GNU lightning: Only currently usable for dynamic runtime emission of binary
58 machine code to memory. Supports one backend at a time.</p>
59
60 <p>LLVM: Supports compilation of C and C++ (with more languages coming soon),
61 strong SSA-based optimization at compile-time, link-time, run-time, and
62 off-line, and multiple platform backends with Just-in-Time and ahead-of-time
63 compilation frameworks. (See our tech report on <a
64 href="http://llvm.cs.uiuc.edu/pubs/2003-09-30-LifelongOptimizationTR.html">Lifelong
65 Code Optimization</a> for more.)</p>
66
67 <p>GCC: Many relatively mature platform backends support assembly-language code
68 generation from many source languages. No run-time compilation
69 support. Relatively weak optimization support.</p>
70 </div>
71
72 <!-- *********************************************************************** -->
73 <div class="doc_section">
74   <a name="typesystem">Type System</a>
75 </div>
76 <!-- *********************************************************************** -->
77
78 <div class="doc_text">
79 <p>GNU lightning: C integer types and "void *" are supported. No type checking
80 is performed. Explicit type casts are not typically necessary unless the
81 underlying machine-specific types are distinct (e.g., sign- or zero-extension is
82 apparently necessary, but casting "int" to "void *" would not be.)
83 Floating-point support may not work on all platforms (it does not appear to be
84 documented in the latest release).</p>
85
86 <p>LLVM: Compositional type system based on C types, supporting structures,
87 opaque types, and C integer and floating point types.</p>
88
89 <p>GCC: Union of high-level types including those used in Pascal, C, C++, Ada,
90 Java, and FORTRAN.</p>
91 </div>
92
93 <!-- *********************************************************************** -->
94 <div class="doc_section">
95   <a name="dataflowinformation">Control-flow and Data-flow Information</a>
96 </div>
97 <!-- *********************************************************************** -->
98
99 <div class="doc_text">
100 <p>GNU lightning: No data-flow information encoded in the generated program. No
101 support for calculating CFG or def-use chains over generated programs.</p>
102
103 <p>LLVM: Scalar values in Static Single-Assignment form; def-use chains and CFG
104 always implicitly available and automatically kept up to date.</p>
105
106 <p>GCC: Trees and RTL do not directly encode data-flow info; but def-use chains
107 and CFGs can be calculated on the side. They are not automatically kept up to
108 date.</p>
109 </div>
110
111 <!-- *********************************************************************** -->
112 <div class="doc_section">
113   <a name="registers">Registers</a>
114 </div>
115 <!-- *********************************************************************** -->
116
117 <div class="doc_text">
118 <p>GNU lightning: Very small fixed register set -- it takes the least common
119 denominator of supported platforms; basically it inherits its tiny register set
120 from IA-32, unnecessarily crippling targets like PowerPC with a large register
121 set.</p>
122
123 <p>LLVM: An infinite register set, reduced to a particular platform's finite
124 register set by register allocator.</p>
125
126 <p>GCC: Trees and RTL provide an arbitrarily large set of values.  Reduced to a
127 particular platform's finite register set by register allocator.</p>
128 </div>
129
130 <!-- *********************************************************************** -->
131 <div class="doc_section">
132   <a name="programmerinterface">Programmer Interface</a>
133 </div>
134 <!-- *********************************************************************** -->
135
136 <div class="doc_text">
137 <p>GNU lightning: Library interface based on C preprocessor macros that emit
138 binary code for a particular instruction to memory. No support for manipulating
139 code before emission.</p>
140
141 <p>LLVM: Library interface based on classes representing platform-independent
142 intermediate code (Instruction) and platform-dependent code (MachineInstr) which
143 can be manipulated arbitrarily and then emitted to memory.</p>
144
145 <p>GCC: Internal header file interface (tree.h) to abstract syntax trees,
146 representing roughly the union of all possible supported source-language
147 constructs; also, an internal header file interface (rtl.h, rtl.def) to a
148 low-level IR called RTL which represents roughly the union of all possible
149 target machine instructions.</p>
150 </div>
151
152 <!-- *********************************************************************** -->
153 <div class="doc_section">
154   <a name="codeemission">Machine Code Emission</a>
155 </div>
156 <!-- *********************************************************************** -->
157
158 <div class="doc_text">
159 <p>GNU lightning: Only supports binary machine code emission to memory.</p>
160
161 <p>LLVM: Supports writing out assembly language to a file, and binary machine
162 code to memory, from the same back-end.</p>
163
164 <p>GCC: Supports writing out assembly language to a file. No support for
165 emitting machine code to memory.</p>
166 </div>
167
168 <!-- *********************************************************************** -->
169
170 <hr>
171 <div class="doc_footer">
172   <address>Brian R. Gaeke</address>
173   <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
174   <br>
175   Last modified: $Date$
176 </div>
177
178 </body>
179 </html>