| Brian Gaeke | e65a8e4 | 2003-11-12 20:19:40 +0000 | [diff] [blame^] | 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 -- the way we see LLVM as | 
 | 40 | being better than and/or different from a few other selected compilers and code | 
 | 41 | 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 | </div> | 
 | 67 |  | 
 | 68 | <p>GCC: Many relatively mature platform backends support assembly-language code | 
 | 69 | generation from many source languages. No run-time compilation | 
 | 70 | support. Relatively weak optimization support.</p> | 
 | 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.) No floating | 
 | 83 | point (?!)</p> | 
 | 84 |  | 
 | 85 | <p>LLVM: Compositional type system based on C types, supporting structures, | 
 | 86 | opaque types, and C integer and floating point types.</p> | 
 | 87 |  | 
 | 88 | <p>GCC: Union of high-level types including those used in Pascal, C, C++, Ada, | 
 | 89 | Java, and FORTRAN.</p> | 
 | 90 | </div> | 
 | 91 |  | 
 | 92 | <!-- *********************************************************************** --> | 
 | 93 | <div class="doc_section"> | 
 | 94 |   <a name="dataflowinformation">Control-flow and Data-flow Information</a> | 
 | 95 | </div> | 
 | 96 | <!-- *********************************************************************** --> | 
 | 97 |  | 
 | 98 | <div class="doc_text"> | 
 | 99 | <p>GNU lightning: No data-flow information encoded in the generated program. No | 
 | 100 | support for calculating CFG or def-use chains over generated programs.</p> | 
 | 101 |  | 
 | 102 | <p>LLVM: Scalar values in Static Single-Assignment form; def-use chains and CFG | 
 | 103 | always implicitly available and automatically kept up to date.</p> | 
 | 104 |  | 
 | 105 | <p>GCC: Trees and RTL do not directly encode data-flow info; but def-use chains | 
 | 106 | and CFGs can be calculated on the side. They are not automatically kept up to | 
 | 107 | date.</p> | 
 | 108 | </div> | 
 | 109 |  | 
 | 110 | <!-- *********************************************************************** --> | 
 | 111 | <div class="doc_section"> | 
 | 112 |   <a name="registers">Registers</a> | 
 | 113 | </div> | 
 | 114 | <!-- *********************************************************************** --> | 
 | 115 |  | 
 | 116 | <div class="doc_text"> | 
 | 117 | <p>GNU lightning: Very small fixed register set -- it takes the least common | 
 | 118 | denominator of supported platforms; basically it inherits its tiny register set | 
 | 119 | from IA-32, unnecessarily crippling targets like PowerPC with a large register | 
 | 120 | set.</p> | 
 | 121 |  | 
 | 122 | <p>LLVM: An infinite register set, reduced to a particular platform's finite | 
 | 123 | register set by register allocator.</p> | 
 | 124 |  | 
 | 125 | <p>GCC: Trees and RTL provide an arbitrarily large set of values.  Reduced to a | 
 | 126 | particular platform's finite register set by register allocator.</p> | 
 | 127 | </div> | 
 | 128 |  | 
 | 129 | <!-- *********************************************************************** --> | 
 | 130 | <div class="doc_section"> | 
 | 131 |   <a name="programmerinterface">Programmer Interface</a> | 
 | 132 | </div> | 
 | 133 | <!-- *********************************************************************** --> | 
 | 134 |  | 
 | 135 | <div class="doc_text"> | 
 | 136 | <p>GNU lightning: Library interface based on C preprocessor macros that emit | 
 | 137 | binary code for a particular instruction to memory. No support for manipulating | 
 | 138 | code before emission.</p> | 
 | 139 |  | 
 | 140 | <p>LLVM: Library interface based on classes representing platform-independent | 
 | 141 | intermediate code (Instruction) and platform-dependent code (MachineInstr) which | 
 | 142 | can be manipulated arbitrarily and then emitted to memory.</p> | 
 | 143 |  | 
 | 144 | <p>GCC: Internal header file interface (tree.h) to abstract syntax trees, | 
 | 145 | representing roughly the union of all possible supported source-language | 
 | 146 | constructs; also, an internal header file interface (rtl.h, rtl.def) to a | 
 | 147 | low-level IR called RTL which represents roughly the union of all possible | 
 | 148 | target machine instructions.</p> | 
 | 149 | </div> | 
 | 150 |  | 
 | 151 | <!-- *********************************************************************** --> | 
 | 152 | <div class="doc_section"> | 
 | 153 |   <a name="codeemission">Machine Code Emission</a> | 
 | 154 | </div> | 
 | 155 | <!-- *********************************************************************** --> | 
 | 156 |  | 
 | 157 | <div class="doc_text"> | 
 | 158 | <p>GNU lightning: Only supports binary machine code emission to memory.</p> | 
 | 159 |  | 
 | 160 | <p>LLVM: Supports writing out assembly language to a file, and binary machine | 
 | 161 | code to memory, from the same back-end.</p> | 
 | 162 |  | 
 | 163 | <p>GCC: Supports writing out assembly language to a file. No support for | 
 | 164 | emitting machine code to memory.</p> | 
 | 165 | </div> | 
 | 166 |  | 
 | 167 | <!-- *********************************************************************** --> | 
 | 168 |  | 
 | 169 | <hr> | 
 | 170 | <div class="doc_footer"> | 
 | 171 |   <address>Brian R. Gaeke</address> | 
 | 172 |   <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a> | 
 | 173 |   <br> | 
 | 174 |   Last modified: $Date$ | 
 | 175 | </div> | 
 | 176 |  | 
 | 177 | </body> | 
 | 178 | </html> |