blob: bd06debbaa64f51dcbfbc7a98745c98c2ef7d8dc [file] [log] [blame]
Brian Gaekee65a8e42003-11-12 20:19:40 +00001<!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
37using it for your projects or not, you may find it useful to understand how we
38compare ourselves to other well-known compilers. The following list of points
Brian Gaeke0c77aeb2003-11-12 21:36:29 +000039should help you understand -- from our point of view -- some of the important
40ways in which we see LLVM as different from other selected compilers and
41code generation systems.</p>
Brian Gaekee65a8e42003-11-12 20:19:40 +000042
43<p>At the moment, we only compare ourselves below to <a
44href="http://gcc.gnu.org/">GCC</a> and <a
45href="http://www.gnu.org/software/lightning/">GNU lightning</a>, but we will try
46to revise and expand it as our knowledge and experience permit. Contributions are
47welcome.</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
58machine 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),
61strong SSA-based optimization at compile-time, link-time, run-time, and
62off-line, and multiple platform backends with Just-in-Time and ahead-of-time
63compilation frameworks. (See our tech report on <a
64href="http://llvm.cs.uiuc.edu/pubs/2003-09-30-LifelongOptimizationTR.html">Lifelong
65Code Optimization</a> for more.)</p>
Brian Gaekee65a8e42003-11-12 20:19:40 +000066
67<p>GCC: Many relatively mature platform backends support assembly-language code
68generation from many source languages. No run-time compilation
69support. Relatively weak optimization support.</p>
Brian Gaeke22f96452003-11-12 20:20:55 +000070</div>
Brian Gaekee65a8e42003-11-12 20:19:40 +000071
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
80is performed. Explicit type casts are not typically necessary unless the
81underlying machine-specific types are distinct (e.g., sign- or zero-extension is
Brian Gaeke78a37102003-11-12 21:38:50 +000082apparently necessary, but casting "int" to "void *" would not be.)
83Floating-point support may not work on all platforms (it does not appear to be
84documented in the latest release).</p>
Brian Gaekee65a8e42003-11-12 20:19:40 +000085
86<p>LLVM: Compositional type system based on C types, supporting structures,
87opaque 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,
90Java, 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
101support 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
104always 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
107and CFGs can be calculated on the side. They are not automatically kept up to
108date.</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
119denominator of supported platforms; basically it inherits its tiny register set
120from IA-32, unnecessarily crippling targets like PowerPC with a large register
121set.</p>
122
123<p>LLVM: An infinite register set, reduced to a particular platform's finite
124register set by register allocator.</p>
125
126<p>GCC: Trees and RTL provide an arbitrarily large set of values. Reduced to a
127particular 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
138binary code for a particular instruction to memory. No support for manipulating
139code before emission.</p>
140
141<p>LLVM: Library interface based on classes representing platform-independent
142intermediate code (Instruction) and platform-dependent code (MachineInstr) which
143can be manipulated arbitrarily and then emitted to memory.</p>
144
145<p>GCC: Internal header file interface (tree.h) to abstract syntax trees,
146representing roughly the union of all possible supported source-language
147constructs; also, an internal header file interface (rtl.h, rtl.def) to a
148low-level IR called RTL which represents roughly the union of all possible
149target 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
162code to memory, from the same back-end.</p>
163
164<p>GCC: Supports writing out assembly language to a file. No support for
165emitting 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>